Editor: Introduce new selectedNote editor state#75177
Conversation
| await this.#page | ||
| .getByRole( 'button', { name: 'Dismiss this notice' } ) | ||
| .filter( { hasText: 'Note added.' } ) | ||
| .click(); |
There was a problem hiding this comment.
This was an actual bug. Clicking outside the note should collapse it, but a race condition prevented this from working.
After the newly created note was deselected, newNoteFormState state changed to closed, re-triggering the Auto-select the related comment thread when a block is selected effect.
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
| /** | ||
| * Select a note by its ID, or clear the selection. | ||
| * | ||
| * @param {undefined|number|'new'} noteId The note ID to select, 'new' to open the new note form, or undefined to clear. |
There was a problem hiding this comment.
We could also use -1 or 0 to indicate a new note form, but the new string seemed clearer.
|
Size Change: +150 B (+0.01%) Total Size: 2.99 MB
ℹ️ View Unchanged
|
0600742 to
f090509
Compare
|
Sorry, no code has changed, but I accidentally merged trunk into this branch 😅 |
t-hamano
left a comment
There was a problem hiding this comment.
Thanks for clarifying, LGTM!
|
Thanks for the review, @t-hamano! I'm going to merge this since this is needed for my other ongoing work. Happy to follow up as needed. All new APIs are private, so there's no problem with making breaking changes. |
Resolve merge conflicts with trunk's selectedNote editor state changes (#75177) while preserving emoji reaction features. Fix all 5 emoji reaction E2E tests that were timing out because the Dropdown popover was stealing focus from the thread, triggering the onBlur handler which collapsed the note and unmounted the emoji picker. - Add focusOnMount: false to the reaction Dropdown popoverProps - Add popover focus check to the thread onBlur handler - Update addReactionToComment E2E helper to wait for the emoji picker Co-Authored-By: Claude Opus 4.6 <[email protected]>
Co-authored-by: Mamaduka <[email protected]> Co-authored-by: t-hamano <[email protected]>
What?
PR introduces a new global state for
selectedNote, along with an associated private action and selector. This is similar to theselectBlockaction.Why?
The local state served us well initially, but it had limitations and blocked integration with other features, such as the Command Palette, Keyboard Shortcuts and RichText formats. It also required a lot of prop drilling.
Most of the code is extracted from my local inline notes format branch.
Todo(s)
Testing Instructions
Testing note focus via action