Skip to content

Commit

Permalink
Prevent crash when clearing the focus of the URL bar
Browse files Browse the repository at this point in the history
This change prevents a crash when clearing the focus of the URL bar
from the wrong thread.
  • Loading branch information
felipeerias authored and svillar committed May 10, 2024
1 parent 67ad3c3 commit 250300e
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1008,16 +1008,17 @@ private void handleDone() {
}
final InputConnection connection = mInputConnection;
final int action = mEditorInfo.imeOptions & EditorInfo.IME_MASK_ACTION;
final boolean hide = (action == EditorInfo.IME_ACTION_DONE) || (action == EditorInfo.IME_ACTION_GO) ||
(action == EditorInfo.IME_ACTION_SEARCH) || (action == EditorInfo.IME_ACTION_SEND);
postInputCommand(() -> postDisplayCommand(() -> {
// Handle the action before clearing the focus, otherwise URL autocomplete will be lost.
connection.performEditorAction(action);

boolean hide = (action == EditorInfo.IME_ACTION_DONE) || (action == EditorInfo.IME_ACTION_GO) ||
(action == EditorInfo.IME_ACTION_SEARCH) || (action == EditorInfo.IME_ACTION_SEND);

if (hide && mFocusedView != null) {
mFocusedView.clearFocus();
}
postUICommand(() -> {
if (hide && mFocusedView != null) {
mFocusedView.clearFocus();
}
});
}));
}

Expand Down

0 comments on commit 250300e

Please sign in to comment.