Skip to content

Preserve note selection on browser tab switch#75955

Merged
Mamaduka merged 1 commit intoWordPress:trunkfrom
im3dabasia:feat/cherrypick-commit-preserve-note-selection
Feb 27, 2026
Merged

Preserve note selection on browser tab switch#75955
Mamaduka merged 1 commit intoWordPress:trunkfrom
im3dabasia:feat/cherrypick-commit-preserve-note-selection

Conversation

@im3dabasia
Copy link
Contributor

@im3dabasia im3dabasia commented Feb 26, 2026

Original code/commit is by @/adamsilverstein

What?

Closes #75640
Prevents notes from collapsing when the browser window or tab loses focus.

Why?

Currently, switching to another window or tab triggers an onBlur event that deselects the active note. This creates friction for users who need to reference external documents while writing notes.

How?

Added a check for document.hasFocus() within the onBlur handlers in add-comment.js and comments.js.

Testing Instructions

  1. Open the editor and add a note to a block.
  2. Keep the note popoveractive.
  3. Switch to a different browser tab or a different application window.
  4. Return to the editor and verify the note remains open and has not collapsed.

Screenshots or screencast

Screencast

Before

Screen.Recording.2026-02-27.at.5.25.48.PM.mov

After

Screen.Recording.2026-02-27.at.5.16.02.PM.mov

Extra video ref: The popover closes when focus is lost within the same tab, but it stays open when switching to other tabs or apps.

Screen.Recording.2026-02-27.at.5.30.36.PM.mov

Check document.hasFocus() in onBlur handlers so that
switching browser tabs or windows does not deselect the
active note, preventing unintended state resets.
@im3dabasia im3dabasia added [Type] Bug An existing feature does not function as intended [Feature] Notes Phase 3 of the Gutenberg roadmap around block commenting labels Feb 26, 2026
@github-actions github-actions bot added the [Package] Editor /packages/editor label Feb 26, 2026
@im3dabasia im3dabasia marked this pull request as ready for review February 27, 2026 12:02
@github-actions
Copy link

github-actions bot commented Feb 27, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: adamsilverstein <adamsilverstein@git.wordpress.org>
Co-authored-by: im3dabasia <im3dabasia1@git.wordpress.org>
Co-authored-by: Mustafabharmal <mustafabharmal@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: joedolson <joedolson@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@im3dabasia
Copy link
Contributor Author

im3dabasia commented Feb 27, 2026

@Mamaduka! When you have a moment, I'd appreciate a review on this.

cc: @joedolson

Copy link
Member

@Mamaduka Mamaduka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @im3dabasia! This looks good ✅

@Mamaduka Mamaduka merged commit d6c0e0b into WordPress:trunk Feb 27, 2026
51 checks passed
@github-actions github-actions bot added this to the Gutenberg 22.7 milestone Feb 27, 2026
@joedolson
Copy link
Contributor

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Notes Phase 3 of the Gutenberg roadmap around block commenting [Package] Editor /packages/editor [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Notes: notes shouldn't collapse when document loses focus

4 participants