mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[web] Use defensive null check in text editing placeElement (#180795)
Fixes #178619 Uses defensive null check (?.) instead of null assertion (!) when calling focusWithoutScroll() on focusedFormElement in GloballyPositionedTextEditingStrategy.placeElement(). This prevents a crash that can occur due to a race condition where hasAutofillGroup returns true but focusedFormElement is null by the time it's accessed.
This commit is contained in:
parent
f363764d92
commit
fc6d13a1b2
@ -1176,7 +1176,11 @@ class GloballyPositionedTextEditingStrategy extends DefaultTextEditingStrategy {
|
||||
// only after placing it to the correct position. Hence autofill menu
|
||||
// does not appear on top-left of the page.
|
||||
// Refocus on the elements after applying the geometry.
|
||||
focusedFormElement!.focusWithoutScroll();
|
||||
// placeForm() involves DOM manipulation which can trigger synchronous
|
||||
// events (like blur). These events might invalidate the current
|
||||
// inputConfiguration or disable the strategy before placeForm() returns.
|
||||
// Therefore, we must defensively check if the element is still valid/present.
|
||||
focusedFormElement?.focusWithoutScroll();
|
||||
moveFocusToActiveDomElement();
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user