-
Notifications
You must be signed in to change notification settings - Fork 236
fix(menu): reset sticky hover state on mouse leave #1827
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
base: main
Are you sure you want to change the base?
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 | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -98,9 +98,9 @@ const Options = forwardRef<HTMLElement, OptionsProps>(function Options( | |||||||||||||
| }} | ||||||||||||||
| key={value} | ||||||||||||||
| value={value} | ||||||||||||||
| selected={selected || (multiple !== true && undefined)} // TODO: undefined? | ||||||||||||||
| selected={selected ? true : undefined} | ||||||||||||||
| disabled={disabled} | ||||||||||||||
| focus={cursor === i || undefined} // TODO: undefined? | ||||||||||||||
| focus={cursor === i ? true : undefined} | ||||||||||||||
| /> | ||||||||||||||
| ); | ||||||||||||||
| } | ||||||||||||||
|
|
@@ -119,6 +119,12 @@ const Options = forwardRef<HTMLElement, OptionsProps>(function Options( | |||||||||||||
| maxHeight={maxHeight} | ||||||||||||||
| onMouseDown={prevent} | ||||||||||||||
| onClick={prevent} | ||||||||||||||
| onMouseLeave={() => { | ||||||||||||||
| // Force browser to recalculate hover states when mouse leaves menu | ||||||||||||||
| if (liRef.current) { | ||||||||||||||
| void liRef.current.offsetHeight; | ||||||||||||||
| } | ||||||||||||||
| }} | ||||||||||||||
|
Comment on lines
+122
to
+127
|
||||||||||||||
| onMouseLeave={() => { | |
| // Force browser to recalculate hover states when mouse leaves menu | |
| if (liRef.current) { | |
| void liRef.current.offsetHeight; | |
| } | |
| }} |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -92,8 +92,8 @@ export const OptionsPaginated = forwardRef<Element, OptionsPaginatedProps>( | |||||
| }} | ||||||
| key={value} | ||||||
| value={value} | ||||||
| selected={selected || (multiple !== true && undefined)} // FIXME: undefined??? | ||||||
| focus={cursor === index || undefined} // FIXME: undefined??? | ||||||
| selected={selected ? true : undefined} | ||||||
|
||||||
| selected={selected ? true : undefined} | |
| selected={selected} |
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.
This change alters the behavior from the original logic. The original code was
selected || (multiple !== true && undefined), which would:truewhen selected is truthyundefinedwhen selected is falsy AND multiple is truefalsewhen selected is falsy AND multiple is false (becausefalse || falseevaluates tofalse)The new code
selected ? true : undefinedalways sets it toundefinedwhen selected is falsy, regardless of the multiple flag. This removes the distinction between single-select and multi-select mode for unselected items.If this behavioral change is intentional, it should be documented. Otherwise, the logic should preserve the original behavior or clarify what the correct behavior should be.