File tree 2 files changed +37
-0
lines changed
packages/ods/src/components/combobox
src/components/ods-combobox
2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -156,6 +156,9 @@ export class OdsCombobox implements OdsFormElement {
156
156
value : value ,
157
157
} ] ;
158
158
this . value = value ;
159
+ if ( this . inputElement ) {
160
+ this . inputElement . value = event . detail . text ;
161
+ }
159
162
}
160
163
this . currentFocusedItemIndex = updateItemsFocus ( this . resultElements , this . currentFocusedItemIndex , 'reset' ) ;
161
164
this . closeDropdown ( ) ;
Original file line number Diff line number Diff line change @@ -618,4 +618,38 @@ describe('ods-combobox behaviour', () => {
618
618
expect ( url . searchParams . get ( 'odsCombobox' ) ) . toBe ( 'value' ) ;
619
619
} ) ;
620
620
} ) ;
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
+ } ) ;
621
655
} ) ;
You can’t perform that action at this time.
0 commit comments