fix: Select component on hover shows invalid title/tooltip 15752 #18740
+44
−12
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.
Closes #15752
Fixed the invalid title/no title in Select component on hovering
Changelog
New
useState
to set the title by the default or theselectedItem
value. onChange updates these title values.Changed
To address the issue, the fix implements the following logic.
Prioritised Default Value
: The code now first attempts to find a child option whose value matches the defaultValue prop. If found, this option's value is used as the default title.Fallback to Selected/First Option
: If no matching defaultValue is found, it falls back to using the value which is already selected, essentially the first in the valueSet, as the default title. This ensures that a title is always set.Removed
Testing / Reviewing
Hover on Select component, it should show the selected Option as tooltip
If there's no option selected, tooltip should not show