-
-
Notifications
You must be signed in to change notification settings - Fork 237
fix(trigger): avoid render-based reset for interaction-level deduplication #601
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -372,9 +372,18 @@ export function generateTrigger( | |
| openRef.current = mergedOpen; | ||
|
|
||
| const lastTriggerRef = React.useRef<boolean[]>([]); | ||
| lastTriggerRef.current = []; | ||
| const resetScheduledRef = React.useRef(false); | ||
|
|
||
| const internalTriggerOpen = useEvent((nextOpen: boolean) => { | ||
| // `lastTriggerRef` is for interaction-level deduplication; do not reset it on render. | ||
| if (!resetScheduledRef.current) { | ||
| resetScheduledRef.current = true; | ||
| queueMicrotask(() => { | ||
| resetScheduledRef.current = false; | ||
| lastTriggerRef.current = []; | ||
| }); | ||
| } | ||
|
||
|
|
||
| setInternalOpen(nextOpen); | ||
|
|
||
| // Enter or Pointer will both trigger open state change | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
6b09c6f
这个直接回滚掉是不是就好了,也不用支持 React 16 了