Thanks to visit codestin.com
Credit goes to GitHub.com

Skip to content

Conversation

@dxsun97
Copy link

@dxsun97 dxsun97 commented Jun 3, 2025

Currently, when dragging/clicking a pane, the pane element will add a dragging class to change the cursor style property from grab to grabbing. As the number of nodes (in other words: the amount of DOM) increases, the time it takes to recalculate the style increases, especially on Chromium-based browsers. There is a known chromium issue here that reveals that modifying the cursor style can cause this problem: https://issues.chromium.org/issues/40493007

So I applied this style change to a single div to avoid recalculating styles for a large number of elements.

This might help resolve the issue: #4527

@changeset-bot
Copy link

changeset-bot bot commented Jun 3, 2025

⚠️ No Changeset found

Latest commit: 4f0e6d0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@moklick
Copy link
Member

moklick commented Jun 3, 2025

Thanks! This is interesting and we will have a look!

@dxsun97
Copy link
Author

dxsun97 commented Jun 9, 2025

Thanks! This is interesting and we will have a look!

Hello, how is it going? I have a project that is troubled by this problem. I hope to solve this problem as soon as possible.

@moklick
Copy link
Member

moklick commented Jun 9, 2025

Unfortunately this would be a breaking change. Some users might use the classes to change the cursor or do other things. We will have another look this week!

@dxsun97
Copy link
Author

dxsun97 commented Jun 16, 2025

Unfortunately this would be a breaking change. Some users might use the classes to change the cursor or do other things. We will have another look this week!

Hi, I found another way to solve this problem: instead of changing the DOM, provide a new prop: paneClassName to override the className of the Pane component, which can avoid breaking changes. What do you think?

@moklick
Copy link
Member

moklick commented Jun 16, 2025

I am not sure if I understand that solution. How would it solve the issue? Can't you overwrite the existing styles if you don't want to change the cursor?

@dxsun97
Copy link
Author

dxsun97 commented Jun 16, 2025

I am not sure if I understand that solution. How would it solve the issue? Can't you overwrite the existing styles if you don't want to change the cursor?

Sorry, I provided some misleading information. In fact, the style recalculation here is because the class attribute of the pane element is changed, and the descendant elements need to be recalculated. Even if its style is overwritten to keep it consistent, the style recalculation still occurs. At present, it seems that the only way to avoid it is to keep the class of the pane element unchanged. This is what I actually did in my PR

@moklick
Copy link
Member

moklick commented Oct 1, 2025

Thanks again! I put it on the React Flow 13 list since it's a breaking change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants