Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/new-experts-occur.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@solid-design-system/components': minor
---

Previously when the user types something in the component `sd-combobox` that is not one of the options, pressing tab would save the "wrong" text in the state. This push fixes that issue. So now when the user types something that is not part of the list/options, pressing tab would delete the text written.
2 changes: 1 addition & 1 deletion packages/components/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ We rely a lot on inline docs to communicate to the library users (developers). W
- `@slot` decorators appear in the Storybook "SLOTS" section
- `@csspart` decorators appear in the Storybook "CSS SHADOW PARTS" section
- `@dependency` decorators appear in the Storybook "PROPERTIES" section under "dependencies".
- `@state` decorators appear in the Storybook "PROPERTIES" section. These should generally be be marked with the JSDoc annotation `/** @internal */` so they do not appear in the docs.
- `@state` decorators appear in the Storybook "PROPERTIES" section. These should generally be marked with the JSDoc annotation `/** @internal */` so they do not appear in the docs.
- `@event` decorators appear in the Storybook "EVENTS" section

## Testing
Expand Down
15 changes: 15 additions & 0 deletions packages/components/src/components/combobox/combobox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,21 @@ export default class SdCombobox extends SolidElement implements SolidFormControl

private handleComboboxKeyDown(event: KeyboardEvent) {
if (event.key === 'Tab') {
const inputValue = this.displayInput.value.trim();

// Check if inputValue matches any option
const matchedOption = this.getSlottedOptions().some(option => {
const optionLabel = option.getTextLabel().toLowerCase();
return optionLabel === inputValue.toLowerCase();
});

// If no match, clear the input
if (!matchedOption) {
this.displayInputValue = '';
// Optionally, you may want to update the input element's value immediately
this.displayInput.value = '';
}

return;
}

Expand Down
Loading