Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update zIndex while calling setParent & deduplicate while translating. #6295

Merged
merged 1 commit into from
Sep 14, 2024

Conversation

HawtinZeng
Copy link
Contributor

  • fix(DataController): after calling graph.addChildrenData(nodeInCombo, [nodeNotInCombo]), can not listen click event of added node.
  • fix(DataController): translateComboBy will make twice tranlations to the same child node of a combo

@HawtinZeng
Copy link
Contributor Author

HawtinZeng commented Sep 7, 2024

Hi, antv teams, there are two flaws I have found, watch the gif below:
screen-capture.webm
screen-capture (1).webm

  1. We need to change the zIndex of child node into the parent node intuitively, when we change to add a node as child of another node, but when we want to move a child node into a combo, we need make nodo zIndex bigger than the combo zIndex.
  2. When when we have two collected nodes included by a combo, the child node will be translated twice in translateComboBy.
    Hope this pr can be helpful.

@HawtinZeng HawtinZeng changed the title 1. fix(DataController): after calling graph.addChildrenData(nodeInCombo, [nodeNotInCombo]), can not listen click event of added node. 2. fix(DataController): translateComboBy will make twice tranlations to the same child node of a combo fix: update zIndex while calling setParent & deduplicate while translating. Sep 7, 2024
@Aarebecca
Copy link
Contributor

Thanks for your contribution, we will confirm and validate this pull request soon.

eleData.style = {};
}
if (this.isCombo(parent)) {
eleData.style.zIndex = parentData.style!.zIndex + 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to add an alternative value when parentData.style.zIndex is undefined, and you can use set and get function which exported from @antv/util to simplify the code,
like:

const zIndex = get(parentData, ['style', 'zIndex'], 0) + this.isCombo(parent) ? 1 : 0;
set(elementData, ['style', 'zIndex'], zIndex);

Copy link
Contributor Author

@HawtinZeng HawtinZeng Sep 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glad to receive your review. We shuldn't change the original action about zIndex, because many(10+ test suits) depend on the original zIndex version. Besides, thanks for your concise code suggestion, we should wrap the ternary with ().

packages/g6/src/runtime/data.ts Outdated Show resolved Hide resolved
@Aarebecca
Copy link
Contributor

It seems that the test snapshots should be updated, you can re-generate related snapshots as follows:

  1. remove current snapshots:
rm -rf packages/g6/__tests__/snapshots/behaviors/drag-element-combo
rm -rf packages/g6/__tests__/snapshots/behaviors/collapse-expand-node
rm -rf packages/g6/__tests__/snapshots/plugins/history/plugin-history
  1. re-generate snapshots:
cd ./packages/g6
npm run test
  1. submit all new snapshots files

@HawtinZeng
Copy link
Contributor Author

All tests passed, maybe the test suit should be less strict.

@HawtinZeng
Copy link
Contributor Author

By the way, these svg changes are messy : (

@Aarebecca
Copy link
Contributor

By the way, these svg changes are messy : (

Generally speaking, a version of the modification will not cause such a huge change in the screenshots. I can't even view the changes on GitHub. I switched to your branch to view yesterday. In fact, only a dozen screenshots need to be updated.

@Aarebecca
Copy link
Contributor

Aarebecca commented Sep 10, 2024

@HawtinZeng The screenshots you updated are located in /__tests__/snapshots/__tests__, which is abnormal. Did you execute the npm run test command under ./packages/g6?

@Aarebecca
Copy link
Contributor

Hi @HawtinZeng , I believe this bug fix is important and should be merged as soon as possible. Here's the pull request: #6320. You can refer to this PR for modifications. If you don’t have time to review it soon, we will close this PR and merge an alternative one.

@HawtinZeng
Copy link
Contributor Author

HawtinZeng commented Sep 11, 2024 via email

@HawtinZeng
Copy link
Contributor Author

HawtinZeng commented Sep 11, 2024

Hi, Aaron, I have tried many ways to pass jest, but failed finally, there are 3 units tests haven't pass, I can pass these tests with running a single test, but can't pass the test when running all tests, maybe some contexts have interference to these failed tests.

@Aarebecca
Copy link
Contributor

Aarebecca commented Sep 12, 2024

@HawtinZeng You can refer to the methods I mentioned earlier. Normal operations should not lead to the problems you encountered. Be sure to note that when you execute the npm run test command, the current terminal path should be under packages/g6. Also, packages/g6/tests/utils/dir.ts is a stable code and it should not be modified.

A simple test review:

  1. Remove all snapshots generated by this pull request
  2. Remove the current G6 snapshots and it should be updated because related code has been modified.
  3. Re-generate snapshots baseline for this pull request

@Aarebecca
Copy link
Contributor

Aarebecca commented Sep 12, 2024

The pull request: #6320 is a standard submit, and your modification scope should not exceed it. (Ignore the coverage)

@HawtinZeng
Copy link
Contributor Author

HawtinZeng commented Sep 12, 2024 via email

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the original test suit is wrong, so I change the zIndex of node-1 to avoid subsequent test errors.

Copy link
Contributor Author

@HawtinZeng HawtinZeng Sep 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Windows, the cwd path is: 'xxx\\xxx\\xxx.xxx', we need path.sep to fix this.

@Aarebecca
Copy link
Contributor

Aarebecca commented Sep 13, 2024

@HawtinZeng The latest commit looks much better, thanks for your efforts, and the final thing is to remove the files under ./packages/g6/__tests__/snapshots/__tests__.
It was an oversight, I didn't realize we were using different operating systems, sorry for the trouble this has caused you.

* fix: deduplicate multiple translations to the same node
* test: update zIndex related snapshots
* fix: deal with path seperator in Windows
@HawtinZeng
Copy link
Contributor Author

Hi, Aarebecca, finished this PR finally.

@Aarebecca Aarebecca changed the base branch from v5 to fix/z-index September 14, 2024 06:38
@Aarebecca Aarebecca merged commit 31f296b into antvis:fix/z-index Sep 14, 2024
1 of 2 checks passed
Aarebecca added a commit that referenced this pull request Sep 14, 2024
* fix: change zIndex in DataController (#6295)

* fix: deduplicate multiple translations to the same node
* test: update zIndex related snapshots
* fix: deal with path seperator in Windows

* test: update test snapshots

---------

Co-authored-by: Hawtin Zeng <73981739+HawtinZeng@users.noreply.github.com>
Co-authored-by: antv <antv@antfin.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants