Skip to content

Commit fd8cec3

Browse files
committed
fix(combobox): combobox reselecting cleared value not visible
1 parent 69f2d09 commit fd8cec3

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

packages/ods/src/components/combobox/src/components/ods-combobox/ods-combobox.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ export class OdsCombobox implements OdsFormElement {
156156
value: value,
157157
}];
158158
this.value = value;
159+
if (this.inputElement) {
160+
this.inputElement.value = event.detail.text;
161+
}
159162
}
160163
this.currentFocusedItemIndex = updateItemsFocus(this.resultElements, this.currentFocusedItemIndex, 'reset');
161164
this.closeDropdown();

packages/ods/src/components/combobox/tests/behaviour/ods-combobox.e2e.ts

+34
Original file line numberDiff line numberDiff line change
@@ -618,4 +618,38 @@ describe('ods-combobox behaviour', () => {
618618
expect(url.searchParams.get('odsCombobox')).toBe('value');
619619
});
620620
});
621+
622+
describe('keyboard navigation', () => {
623+
it('should allow to select a value, delete it with keyboard and reselect it in single mode', async() => {
624+
await setup(`
625+
<ods-combobox allow-new-element="false">
626+
<ods-combobox-item value="test">Test value</ods-combobox-item>
627+
</ods-combobox>
628+
`);
629+
const odsChangeSpy = await page.spyOnEvent('odsChange');
630+
631+
await openList();
632+
await input.press('ArrowDown');
633+
await input.press('Enter');
634+
await page.waitForChanges();
635+
636+
expect(await el.getProperty('value')).toBe('test');
637+
expect(await input.getProperty('value')).toBe('Test value');
638+
expect(odsChangeSpy).toHaveReceivedEventTimes(1);
639+
640+
await input.press('Backspace');
641+
await page.waitForChanges();
642+
643+
expect(await el.getProperty('value')).toBe('test');
644+
expect(await input.getProperty('value')).toBe('Test valu');
645+
646+
await openList();
647+
await input.press('ArrowDown');
648+
await input.press('Enter');
649+
await page.waitForChanges();
650+
651+
expect(await el.getProperty('value')).toBe('test');
652+
expect(await input.getProperty('value')).toBe('Test value');
653+
});
654+
});
621655
});

0 commit comments

Comments
 (0)