Skip to content

[593] Fix the editor losing the focus when a note is created from the FAB - #594

Closed
maelchiotti wants to merge 1 commit into
v2.3.0from
fix/593_fab_editor_focus
Closed

maelchiotti wants to merge 1 commit into
v2.3.0from
fix/593_fab_editor_focus

Conversation

@maelchiotti

@maelchiotti maelchiotti commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

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

ExpandableFab closes with a 250 ms animation and wraps its buttons in a FocusScope while it is not fully closed. That FocusScope is 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_fab 2.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.
  • AddNoteFab waits for the end of the closing animation (afterClose) before calling addNote. 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). mounted is checked before using the context.
  • The other caller (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.
  • Not tested on a device: the cloud environment has no emulator. To test: with at least two note types enabled, create a note of each type from the expandable FAB (on the notes page and on a label page), and check that the keyboard stays open.

…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>
@maelchiotti maelchiotti added the bug Something isn't working label Nov 13, 2026 — with Claude
@maelchiotti maelchiotti self-assigned this Nov 13, 2026

This branch was successfully deployed

1 active deployment
build — 9095a318 Deployed Nov 13, 2026 by maelchiotti via Android #818
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants