@@ -270,7 +270,8 @@ def _complete(self, option_index: int) -> None:
270
270
highlighted = option_index
271
271
option = cast (DropdownItem , option_list .get_option_at_index (highlighted ))
272
272
highlighted_value = option .value
273
- self .apply_completion (highlighted_value , self ._get_target_state ())
273
+ with self .prevent (Input .Changed ):
274
+ self .apply_completion (highlighted_value , self ._get_target_state ())
274
275
self .post_completion ()
275
276
276
277
def post_completion (self ) -> None :
@@ -284,18 +285,17 @@ def apply_completion(self, value: str, state: TargetState) -> None:
284
285
the value the user has chosen from the dropdown list.
285
286
"""
286
287
target = self .target
287
- with self .prevent (Input .Changed ):
288
- target .value = ""
289
- target .insert_text_at_cursor (value )
290
-
291
- # We need to rebuild here because we've prevented the Changed events
292
- # from being sent to the target widget, meaning AutoComplete won't spot
293
- # intercept that message, and would not trigger a rebuild like it normally
294
- # does when a Changed event is received.
295
- new_target_state = self ._get_target_state ()
296
- self ._rebuild_options (
297
- new_target_state , self .get_search_string (new_target_state )
298
- )
288
+ target .value = ""
289
+ target .insert_text_at_cursor (value )
290
+
291
+ # We need to rebuild here because we've prevented the Changed events
292
+ # from being sent to the target widget, meaning AutoComplete won't spot
293
+ # intercept that message, and would not trigger a rebuild like it normally
294
+ # does when a Changed event is received.
295
+ new_target_state = self ._get_target_state ()
296
+ self ._rebuild_options (
297
+ new_target_state , self .get_search_string (new_target_state )
298
+ )
299
299
300
300
@property
301
301
def target (self ) -> Input :
0 commit comments