@@ -37,6 +37,14 @@ export function init(id, invoke) {
3737 } )
3838 }
3939
40+ EventHandler . on ( input , 'blur' , e => {
41+ el . classList . remove ( 'show' ) ;
42+ const triggerBlur = input . getAttribute ( 'data-bb-blur' ) === 'true' ;
43+ if ( triggerBlur ) {
44+ invoke . invokeMethodAsync ( 'TriggerBlur' ) ;
45+ }
46+ } ) ;
47+
4048 EventHandler . on ( input , 'focus' , e => {
4149 const showDropdownOnFocus = input . getAttribute ( 'data-bb-auto-dropdown-focus' ) === 'true' ;
4250 if ( showDropdownOnFocus ) {
@@ -48,10 +56,6 @@ export function init(id, invoke) {
4856
4957 EventHandler . on ( menu , 'click' , e => {
5058 el . classList . remove ( 'show' ) ;
51- if ( el . triggerEnter !== true ) {
52- invoke . invokeMethodAsync ( 'TriggerBlur' ) ;
53- }
54- delete el . triggerEnter ;
5559 } ) ;
5660
5761 EventHandler . on ( input , 'change' , e => {
@@ -93,11 +97,7 @@ export function init(id, invoke) {
9397
9498 const el = a . querySelector ( '[data-bs-toggle="bb.dropdown"]' ) ;
9599 if ( el === null ) {
96- const id = a . getAttribute ( 'id' ) ;
97- const ac = Data . get ( id ) ;
98- if ( ac ) {
99- triggerBlurEvent ( ac ) ;
100- }
100+ a . classList . remove ( 'show' ) ;
101101 }
102102 } ) ;
103103 } ) ;
@@ -109,15 +109,6 @@ export function init(id, invoke) {
109109 window . BootstrapBlazor . AutoComplete . registerCloseDropdownHandler ( ) ;
110110}
111111
112- const triggerBlurEvent = ac => {
113- const { el, invoke, input } = ac ;
114- el . classList . remove ( 'show' ) ;
115- const triggerBlur = input . getAttribute ( 'data-bb-blur' ) === 'true' ;
116- if ( triggerBlur ) {
117- invoke . invokeMethodAsync ( 'TriggerBlur' ) ;
118- }
119- }
120-
121112const handlerKeyup = ( ac , e ) => {
122113 const key = e . key ;
123114 const { el, input, invoke, menu } = ac ;
@@ -126,7 +117,6 @@ const handlerKeyup = (ac, e) => {
126117 if ( ! skipEnter ) {
127118 const current = menu . querySelector ( '.active' ) ;
128119 if ( current !== null ) {
129- el . triggerEnter = true ;
130120 current . click ( ) ;
131121 }
132122 invoke . invokeMethodAsync ( 'EnterCallback' , input . value ) ;
@@ -136,7 +126,6 @@ const handlerKeyup = (ac, e) => {
136126 const skipEsc = el . getAttribute ( 'data-bb-skip-esc' ) === 'true' ;
137127 if ( skipEsc === false ) {
138128 input . blur ( ) ;
139- triggerBlurEvent ( ac ) ;
140129 invoke . invokeMethodAsync ( 'EscCallback' ) ;
141130 }
142131 }
@@ -186,6 +175,7 @@ export function dispose(id) {
186175 }
187176 }
188177 EventHandler . off ( input , 'keyup' ) ;
178+ EventHandler . off ( input , 'blur' ) ;
189179 EventHandler . off ( menu , 'click' ) ;
190180 Input . dispose ( input ) ;
191181 }
0 commit comments