Repository navigation
Notes: Preserve unsent note and reply drafts - #84110
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
c8ff08f to
c8a724d
Compare
🤖 PR meta 🤖🎉 PropsIf 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. Updated as activity occurs, without notifying anyone named here. Add the 📦 Bundle sizeSize Change: +178 B (0%) Total Size: 8.29 MB 📦 View Changed
⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
🏁 Flaky testsSome tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information. refuses the drop and uploads nothing in
|
|
Marking this ready to review. Re: Inline note draftsThe tricky part is the anchor. With drafts, the form outlives the text selection, so we need to keep the range somewhere and track it while the content changes. Google Docs and Notion handle this with a placeholder highlight on the selected text while you write the note. It goes away on cancel and becomes the real marker on submit. I'd like to experiment with something similar: a highlight that exists only in the editor and is never saved in the content. It's more involved than block and reply drafts, so it will probably be a follow-up. |
| }; | ||
| }, [] ); | ||
|
|
||
| // Select the block's primary note, or clear the selection if it has none. |
There was a problem hiding this comment.
is this comment block removal intentional?
There was a problem hiding this comment.
Sort of, it's more a result of my aggressive comment pruning. Happy to restore, but the L580-581 logic seems clear to me.
|
Nice work, I like this approach. I tested this with block level and selection notes and while I see the anchor issue you mentioned, it still feels fine to land as is for now. |
|
Thanks, @adamsilverstein! |
Trunk's draft-preserving reply form (#84110) carries the note class, so the hover locator matched two elements. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L7rwHtVAa37GWJPC8P3Cwd
What?
Closes #73473
Keeps the text typed into the new note and reply forms when the form closes because another block or thread was selected, or the editor switched to the code editor. Today, typing a note, clicking another block and coming back shows an empty form.
Why?
NoteFormholds its content in local state, and the form only renders while its note is selected, so any selection change unmounts it and drops the text. Window and tab switches were fixed in #80222; block and thread switches are what remain.How?
Drafts live in a
Mapowned byNotesSidebarContainer, keyed by block client ID (new note) or note ID (reply);useNoteDraftreads it when a form mounts and writes it on change, so typing doesn't re-render the sidebar, and the owner sits above the code editor and revisions checks. Selecting a block with no threads but a draft selects'new', which reopens the form, and a non-empty new note form stays open on focus-out (as long as the same block is selected).Alternative to #80482, which mirrors every keystroke into the editor store.
Testing Instructions
Testing Instructions for Keyboard
Same.
Use of AI Tools
Assisted by Claude.