Repository navigation
fix(useDropArea): preserve over state across child transitions - #2741
Open
wanxiankai wants to merge 1 commit into
Open
wanxiankai wants to merge 1 commit into
wanxiankai wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Dragging into a child of a
useDropAreaelement produces a bubblingdragenterfollowed by adragleavefor the previous element. The current leave handler immediately setsovertofalse, even though the drag remains inside the drop area.Track balanced drag entries in a ref and clear
overonly when the last entry leaves. Keeping the count outside the memoized handlers preserves it when callbacks change during a drag. Reset the count on drop and clamp it at zero so a subsequent drag starts cleanly even if an extradragleavefollows the drop.Fixes #2368.
Add a nested-child Storybook example and document the expected hover state.
Validation
relatedTarget, nested drop areas, callback changes, repeated drags after a drop, and existing URI/file/text/paste handling.yarn test: 77 suites / 507 tests pass.src/useDropArea.ts.yarn lint:typesandyarn build(CommonJS and ES modules): pass.yarn lint: 0 errors, 97 existing warnings. The hook's existinguseMemodependency warning also occurs on the unmodified source.git diff --check: pass.overfromtruetofalsewhen entering a descendant; the fix keeps ittrueacross descendants and siblings, sets itfalseon exit, and handles re-entry and a URI drop correctly. The recorded browser drag events are trusted.Type of change
Checklist
yarn test)yarn lint). Fix it withyarn lint:fixin case of failure.yarn lint:types).Prepared with AI assistance.