Skip to content

Commit

Permalink
fix: dev sync comments
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiashader committed Nov 28, 2024
1 parent 2c0e1f0 commit 083fcd0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
1 change: 0 additions & 1 deletion .changeset/good-mayflies-accept.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
'storybook-docs': patch
'@siemens/ix-react': patch
'@siemens/ix': patch
'@siemens/ix-vue': patch
Expand Down
18 changes: 10 additions & 8 deletions packages/core/src/components/select/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ export class Select implements IxInputFieldComponent<string | string[]> {
this.cleanupResources();
}

private itemExists(item: string) {
private itemExists(item: string | undefined) {
return this.items.find((i) => i.label === item);
}

Expand Down Expand Up @@ -551,15 +551,17 @@ export class Select implements IxInputFieldComponent<string | string[]> {
return;
}

const trimmedInput = this.inputFilterText.trim();
const itemLabel = (el as HTMLIxSelectItemElement)?.label;

if (
!this.itemExists(this.inputFilterText.trim()) &&
!this.itemExists((el as HTMLIxSelectItemElement)?.label ?? '')
this.editable &&
!this.itemExists(trimmedInput) &&
!this.itemExists(itemLabel)
) {
if (this.editable) {
const defaultPrevented = this.emitAddItem(this.inputFilterText.trim());
if (defaultPrevented) {
return;
}
const defaultPrevented = this.emitAddItem(trimmedInput);
if (defaultPrevented) {
return;
}
}

Expand Down
22 changes: 13 additions & 9 deletions packages/storybook-docs/src/stories/select.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const meta = {
parameters: {
design: {
type: 'figma',
url: 'https://www.figma.com/design/r2nqdNNXXZtPmWuVjIlM1Q/iX-Components---Brand-Dark?node-id=594-9899&m=dev',
url: 'https://www.figma.com/design/r2nqdNNXXZtPmWuVjIlM1Q/iX-Components---Brand-Dark?node-id=42365-175539&m=dev',
},
},
} satisfies Meta<Element>;
Expand All @@ -34,14 +34,18 @@ export const Default: Story = {
};

export const editableSelect: Story = {
render: ({ value, editable, allowClear, disabled, }) => {
return html`
<ix-select value=${value} ?editable=${editable} ?allow-clear=${allowClear} disabled=${disabled}>
<ix-select-item label="Item 1" value="1"></ix-select-item>
<ix-select-item label="Item 2" value="2"></ix-select-item>
<ix-select-item label="Item 3" value="3"></ix-select-item>
<ix-select-item label="Item 4" value="4"></ix-select-item>
</ix-select>`;
render: ({ value, editable, allowClear, disabled }) => {
return html` <ix-select
value=${value}
?editable=${editable}
?allow-clear=${allowClear}
disabled=${disabled}
>
<ix-select-item label="Item 1" value="1"></ix-select-item>
<ix-select-item label="Item 2" value="2"></ix-select-item>
<ix-select-item label="Item 3" value="3"></ix-select-item>
<ix-select-item label="Item 4" value="4"></ix-select-item>
</ix-select>`;
},
args: {
value: 'Administrator',
Expand Down

0 comments on commit 083fcd0

Please sign in to comment.