File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
src/BootstrapBlazor/Components/AutoComplete Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -106,8 +106,20 @@ export function init(id, invoke) {
106106 }
107107 } ) ;
108108 }
109+ ac . blur = e => {
110+ if ( e . key === 'Tab' ) {
111+ [ ...document . querySelectorAll ( '.auto-complete.show' ) ] . forEach ( a => {
112+ const id = a . getAttribute ( 'id' ) ;
113+ const d = Data . get ( id ) ;
114+ if ( d ) {
115+ d . close ( ) ;
116+ }
117+ } ) ;
118+ }
119+ }
109120 registerBootstrapBlazorModule ( 'AutoComplete' , id , ( ) => {
110121 EventHandler . on ( document , 'click' , ac . closePopover ) ;
122+ EventHandler . on ( document , 'keyup' , ac . blur ) ;
111123 } ) ;
112124}
113125
@@ -131,7 +143,7 @@ const handlerKeyup = (ac, e) => {
131143 }
132144 }
133145 else if ( key === 'ArrowUp' || key === 'ArrowDown' ) {
134- el . classList . add ( ' show' ) ;
146+ ac . show ( ) ;
135147 const items = [ ...menu . querySelectorAll ( '.dropdown-item' ) ] ;
136148 let current = menu . querySelector ( '.active' ) ;
137149 if ( current !== null ) {
@@ -171,6 +183,7 @@ export function dispose(id) {
171183 const { AutoComplete } = window . BootstrapBlazor ;
172184 AutoComplete . dispose ( id , ( ) => {
173185 EventHandler . off ( document , 'click' , ac . closePopover ) ;
186+ EventHandler . off ( document , 'keyup' , ac . blur ) ;
174187 } ) ;
175188}
176189
You can’t perform that action at this time.
0 commit comments