-
Notifications
You must be signed in to change notification settings - Fork 15
fix(container-menu): ensure outside clicks always close dropdown menu #699
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 all commits
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 |
|---|---|---|
|
|
@@ -26,7 +26,7 @@ export const triggerLink = (element: HTMLAnchorElement, view: Window) => { | |
| }; | ||
|
|
||
| export const StateChangeTypes: Record<string, string> = { | ||
| FnSetStateRefs: 'fn:setStateRefs', | ||
| FnInternalUpdate: 'fn:internalUpdate', | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Although the new naming might be preferable, are we concerned this introduces a corner case breaking change? Would it make sense to leave
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the only |
||
| FnMenuTransitionFinish: 'fn:menuTransitionFinish', | ||
| TriggerClick: 'trigger:click', | ||
| TriggerKeyDownEnter: `trigger:keyDown:${KEYS.ENTER}`, | ||
|
|
@@ -98,12 +98,6 @@ type ReducerAction = { | |
| export const stateReducer: Reducer<ReducerState, ReducerAction> = (state, action) => { | ||
| let changes: ReducerState | null = null; | ||
|
|
||
| // Reset `focusOnOpen` if it was previously set to true; this prevents | ||
| // forced focus on the initial item in future state updates. | ||
| if (state.focusOnOpen) { | ||
| changes = { ...state, focusOnOpen: false }; | ||
| } | ||
|
|
||
|
Comment on lines
-101
to
-106
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
| switch (action.type) { | ||
| case StateChangeTypes.MenuBlur: | ||
| case StateChangeTypes.MenuKeyDownEscape: | ||
|
|
@@ -118,7 +112,7 @@ export const stateReducer: Reducer<ReducerState, ReducerAction> = (state, action | |
|
|
||
| if (stateChanges) { | ||
| changes = { | ||
| ...(changes || state), | ||
| ...state, | ||
| ...stateChanges | ||
| }; | ||
| } | ||
|
|
@@ -150,7 +144,7 @@ export const stateReducer: Reducer<ReducerState, ReducerAction> = (state, action | |
|
|
||
| if (stateChanges) { | ||
| changes = { | ||
| ...(changes || state), | ||
| ...state, | ||
| ...stateChanges | ||
| }; | ||
| } | ||
|
|
@@ -183,7 +177,7 @@ export const stateReducer: Reducer<ReducerState, ReducerAction> = (state, action | |
|
|
||
| if (stateChanges) { | ||
| changes = { | ||
| ...(changes || state), | ||
| ...state, | ||
| ...stateChanges | ||
| }; | ||
| } | ||
|
|
@@ -197,7 +191,7 @@ export const stateReducer: Reducer<ReducerState, ReducerAction> = (state, action | |
|
|
||
| if (stateChanges) { | ||
| changes = { | ||
| ...(changes || state), | ||
| ...state, | ||
| ...stateChanges, | ||
| transitionType: null, | ||
| isTransitionNext: false, | ||
|
|
@@ -208,10 +202,10 @@ export const stateReducer: Reducer<ReducerState, ReducerAction> = (state, action | |
| break; | ||
| } | ||
|
|
||
| case StateChangeTypes.FnSetStateRefs: { | ||
| case StateChangeTypes.FnInternalUpdate: { | ||
| const { ...props } = action.payload; | ||
|
|
||
| changes = { ...(changes || state), ...props }; | ||
| changes = { ...state, ...props }; | ||
|
|
||
| break; | ||
| } | ||
|
|
||
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.
Memory leaks are unlikely here since
setTimeout(..., 0)runs almost immediately. However, it's still good to follow best practices.