Repository navigation
[593] Fix the editor losing the focus when a note is created from the FAB - #594
Closed
maelchiotti wants to merge 1 commit into
Closed
maelchiotti wants to merge 1 commit into
maelchiotti wants to merge 1 commit into
Conversation
…itor The expandable FAB wraps its buttons in a FocusScope while it is not fully closed, and removes it when its 250 ms closing animation ends. Closing the FAB and pushing the editor in the same frame (#583) made the editor take the focus first, then lose it, and the keyboard closed, when the animation ended. closeAddNoteFabIfOpen() now returns whether the FAB started to close, and the FAB waits for its closing animation (with a timeout, in case it cannot complete) before adding the note. Refs #593 Co-Authored-By: Claude <noreply@anthropic.com>
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #593
Problem
When several note types are enabled, creating a note from the expandable FAB opens the editor and focuses it, but the focus (and the keyboard) is lost about 250 ms later. #583 closed the FAB before opening the editor, which was not enough.
Cause
ExpandableFabcloses with a 250 ms animation and wraps its buttons in aFocusScopewhile it is not fully closed. ThatFocusScopeis removed when the animation ends, which unfocuses whatever was focused in the meantime.closeAddNoteFabIfOpen()only started the animation, so the editor was pushed and focused while the FAB was still closing, then lost the focus when the animation ended.I reproduced it with a widget test using
flutter_expandable_fab2.5.2 (outside the repository, which has no tests): with the route pushed right after toggling the FAB, the editor has the focus until 225 ms and none from 250 ms. With the route pushed after the animation, the editor keeps the focus.Changes
closeAddNoteFabIfOpen()returns whether a FAB was open and started to close.AddNoteFabwaits for the end of the closing animation (afterClose) before callingaddNote. A 500 ms timeout makes sure the note is still created if the animation cannot complete (for example if the FAB is tapped while it is still opening).mountedis checked before using the context.note_tile.dart, opening an existing note) is unchanged: it does not use the returned value.Opening the editor now starts after the 250 ms animation, only when the FAB was open (several note types). With a single note type there is no delay.
Checks
dart format -l 120,dart analyze --fatal-infos(Flutter 3.44.0, code generated): no issue.