@@ -6,6 +6,7 @@ export default class Combobox {
66 input : HTMLTextAreaElement | HTMLInputElement
77 keyboardEventHandler : ( event : KeyboardEvent ) => void
88 compositionEventHandler : ( event : Event ) => void
9+ inputHandler : ( event : Event ) => void
910
1011 constructor ( input : HTMLTextAreaElement | HTMLInputElement , list : HTMLElement ) {
1112 this . input = input
@@ -20,6 +21,7 @@ export default class Combobox {
2021
2122 this . keyboardEventHandler = event => keyboardBindings ( event , this )
2223 this . compositionEventHandler = event => trackComposition ( event , this )
24+ this . inputHandler = this . clearSelection . bind ( this )
2325 input . setAttribute ( 'role' , 'combobox' )
2426 input . setAttribute ( 'aria-controls' , list . id )
2527 input . setAttribute ( 'aria-expanded' , 'false' )
@@ -42,6 +44,7 @@ export default class Combobox {
4244 this . input . setAttribute ( 'aria-expanded' , 'true' )
4345 this . input . addEventListener ( 'compositionstart' , this . compositionEventHandler )
4446 this . input . addEventListener ( 'compositionend' , this . compositionEventHandler )
47+ this . input . addEventListener ( 'input' , this . inputHandler )
4548 ; ( this . input as HTMLElement ) . addEventListener ( 'keydown' , this . keyboardEventHandler )
4649 this . list . addEventListener ( 'click' , commitWithElement )
4750 }
@@ -51,6 +54,7 @@ export default class Combobox {
5154 this . input . setAttribute ( 'aria-expanded' , 'false' )
5255 this . input . removeEventListener ( 'compositionstart' , this . compositionEventHandler )
5356 this . input . removeEventListener ( 'compositionend' , this . compositionEventHandler )
57+ this . input . removeEventListener ( 'input' , this . inputHandler )
5458 ; ( this . input as HTMLElement ) . removeEventListener ( 'keydown' , this . keyboardEventHandler )
5559 this . list . removeEventListener ( 'click' , commitWithElement )
5660 }
@@ -128,6 +132,7 @@ function keyboardBindings(event: KeyboardEvent, combobox: Combobox) {
128132 }
129133 break
130134 default :
135+ if ( ctrlBindings && event . ctrlKey ) break
131136 combobox . clearSelection ( )
132137 }
133138}
0 commit comments