-
Notifications
You must be signed in to change notification settings - Fork 106
fix(ui-selectable,ui-select): fix typing of Select and Selectable eve… #2289
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
Merged
ToMESSKa
merged 1 commit into
master
from
INSTUI-4866-selects-handle-show-options-and-perhaps-other-events-are-wrongly-typed
Dec 23, 2025
+87
−71
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,13 +44,15 @@ type: example | |
| setIsShowingOptions(true) | ||
| if (inputValue || selectedOptionId || options.length === 0) return | ||
|
|
||
| switch (event.key) { | ||
| case 'ArrowDown': | ||
| return handleHighlightOption(event, { id: options[0].id }) | ||
| case 'ArrowUp': | ||
| return handleHighlightOption(event, { | ||
| id: options[options.length - 1].id | ||
| }) | ||
| if ('key' in event) { | ||
| switch (event.key) { | ||
| case 'ArrowDown': | ||
| return handleHighlightOption(event, { id: options[0].id }) | ||
| case 'ArrowUp': | ||
| return handleHighlightOption(event, { | ||
| id: options[options.length - 1].id | ||
| }) | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -234,13 +236,15 @@ type: example | |
| ) | ||
| if (inputValue || selectedOptionId || options.length === 0) return | ||
|
|
||
| switch (event.key) { | ||
| case 'ArrowDown': | ||
| return handleHighlightOption(event, { id: options[0].id }) | ||
| case 'ArrowUp': | ||
| return handleHighlightOption(event, { | ||
| id: options[options.length - 1].id | ||
| }) | ||
| if ('key' in event) { | ||
| switch (event.key) { | ||
| case 'ArrowDown': | ||
| return handleHighlightOption(event, { id: options[0].id }) | ||
| case 'ArrowUp': | ||
| return handleHighlightOption(event, { | ||
| id: options[options.length - 1].id | ||
| }) | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -436,21 +440,23 @@ type: example | |
|
|
||
| if (inputValue || options.length === 0) return | ||
|
|
||
| switch (event.key) { | ||
| case 'ArrowDown': | ||
| return handleHighlightOption(event, { | ||
| id: options.find((option) => !selectedOptionId.includes(option.id)) | ||
| .id | ||
| }) | ||
| case 'ArrowUp': | ||
| // Highlight last non-selected option | ||
| return handleHighlightOption(event, { | ||
| id: options[ | ||
| options.findLastIndex( | ||
| (option) => !selectedOptionId.includes(option.id) | ||
| ) | ||
| ].id | ||
| }) | ||
| if ('key' in event) { | ||
| switch (event.key) { | ||
| case 'ArrowDown': | ||
| return handleHighlightOption(event, { | ||
| id: options.find((option) => !selectedOptionId.includes(option.id)) | ||
| .id | ||
| }) | ||
| case 'ArrowUp': | ||
| // Highlight last non-selected option | ||
| return handleHighlightOption(event, { | ||
| id: options[ | ||
| options.findLastIndex( | ||
| (option) => !selectedOptionId.includes(option.id) | ||
| ) | ||
| ].id | ||
| }) | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -489,13 +495,13 @@ type: example | |
| const newOptions = filterOptions(value) | ||
| setInputValue(value) | ||
| setFilteredOptions(newOptions) | ||
| sethHighlightedOptionId(newOptions.length > 0 ? newOptions[0].id : null) | ||
|
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 was a typo
Collaborator
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. We should really type check these somehow... |
||
| setHighlightedOptionId(newOptions.length > 0 ? newOptions[0].id : null) | ||
| setIsShowingOptions(true) | ||
| setAnnouncement(getOptionsChangedMessage(newOptions)) | ||
| } | ||
|
|
||
| const handleKeyDown = (event) => { | ||
| if (event.keyCode === 8) { | ||
| if ('keyCode' in event && event.keyCode === 8) { | ||
| // when backspace key is pressed | ||
| if (inputValue === '' && selectedOptionId.length > 0) { | ||
| // remove last selected option, if input has no entered text | ||
|
|
@@ -660,17 +666,19 @@ const GroupSelectExample = ({ options }) => { | |
| const handleShowOptions = (event) => { | ||
| setIsShowingOptions(true) | ||
| setHighlightedOptionId(null) | ||
| if (inputValue || selectedOptionId || options.length === 0) return | ||
| if (inputValue || selectedOptionId || Object.keys(options).length === 0) return | ||
|
|
||
| switch (event.key) { | ||
| case 'ArrowDown': | ||
| return handleHighlightOption(event, { | ||
| id: options[Object.keys(options)[0]][0].id | ||
| }) | ||
| case 'ArrowUp': | ||
| return handleHighlightOption(event, { | ||
| id: Object.values(options).at(-1)?.at(-1)?.id | ||
| }) | ||
| if ('key' in event) { | ||
| switch (event.key) { | ||
| case 'ArrowDown': | ||
| return handleHighlightOption(event, { | ||
| id: options[Object.keys(options)[0]][0].id | ||
| }) | ||
| case 'ArrowUp': | ||
| return handleHighlightOption(event, { | ||
| id: Object.values(options).at(-1)?.at(-1)?.id | ||
| }) | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -840,17 +848,19 @@ const GroupSelectAutocompleteExample = ({ options }) => { | |
| setIsShowingOptions(true) | ||
| setHighlightedOptionId(null) | ||
|
|
||
| if (inputValue || selectedOptionId || options.length === 0) return | ||
| if (inputValue || selectedOptionId || Object.keys(options).length === 0) return | ||
|
|
||
| switch (event.key) { | ||
| case 'ArrowDown': | ||
| return handleHighlightOption(event, { | ||
| id: options[Object.keys(options)[0]][0].id | ||
| }) | ||
| case 'ArrowUp': | ||
| return handleHighlightOption(event, { | ||
| id: Object.values(options).at(-1)?.at(-1)?.id | ||
| }) | ||
| if ('key' in event) { | ||
| switch (event.key) { | ||
| case 'ArrowDown': | ||
| return handleHighlightOption(event, { | ||
| id: options[Object.keys(options)[0]][0].id | ||
| }) | ||
| case 'ArrowUp': | ||
| return handleHighlightOption(event, { | ||
| id: Object.values(options).at(-1)?.at(-1)?.id | ||
| }) | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -1205,13 +1215,15 @@ const SingleSelectExample = ({ options }) => { | |
|
|
||
| if (inputValue || selectedOptionId || options.length === 0) return | ||
|
|
||
| switch (event.key) { | ||
| case 'ArrowDown': | ||
| return handleHighlightOption(event, { id: options[0].id }) | ||
| case 'ArrowUp': | ||
| return handleHighlightOption(event, { | ||
| id: options[options.length - 1].id | ||
| }) | ||
| if ('key' in event) { | ||
| switch (event.key) { | ||
| case 'ArrowDown': | ||
| return handleHighlightOption(event, { id: options[0].id }) | ||
| case 'ArrowUp': | ||
| return handleHighlightOption(event, { | ||
| id: options[options.length - 1].id | ||
| }) | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
I changed a few examples in README a bit to make them TypeScript error-free