-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Ensure "Add Note" component floats next to block in unpinned mode #72494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Size Change: +265 B (+0.01%) Total Size: 2.37 MB
ℹ️ View Unchanged
|
|
Flaky tests detected in a555502. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/18843942045
|
|
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. |
|
This is working fairly well in my testing Remaining issues:
|
This is fixed in 549838f |
This is fixed in dcf659f |
|
This is close, I still see one issue where the new comment block is not placed in the right position. I will work on addressing. |
Mamaduka
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting approach, @adamsilverstein!
As you said, it needs some polishing, but it is also working :)
Thanks for the review and feedback. My initial attempt at this was to make the AddComment component itself float, however given the need to keep the threads from overlapping, I found the current approach to be way more reliable. I'll work on the code polish you suggested. The main remaining glitch I see when testing this out is after opening the new note popup, selecting a different block without an existing comment should move the new comment form to be aligned with that block, currently it does not. |
Mamaduka
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this, @adamsilverstein!
I think this is ready to merge, but I would appreciate a little more help with testing from others. cc @jasmussen, @t-hamano
Here are the changes I made:
- Merged the latest trunk.
- Fixed failing e2e test and did minor cleanup.
- Added logic to close the new note form when the user moves focus outside. This allows us to remove separate reflow logic.
| orderedBlockIds.forEach( ( blockId ) => { | ||
| if ( blockId === selectedBlockClientId ) { | ||
| orderedThreads.push( newNoteThread ); | ||
| } else { | ||
| const threadForBlock = t.find( | ||
| ( thread ) => thread.blockClientId === blockId | ||
| ); | ||
| if ( threadForBlock ) { | ||
| orderedThreads.push( threadForBlock ); | ||
| } | ||
| } | ||
| } ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, why did you change from the previous index-based logic to this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the index based logic didn't take into account that not all blocks have associated notes. the index it found was in the block order, which I then tried applying directly to the notes collection. As a result, it didn't find the right spot to insert the new note thread.
|
This is testing fairly well for me, and I can't break it: Notably I like that there's animation when the canvas scales down to make room for a note. And in that similar vein, but not something that has to be fixed in this cycle, between the "input note" being submitted, and the final note appearing, there's a small blink where the note disappears, then reappears. I imagine there are foundational technical reasons for why this is so, but conceptually it is the same note, so a bit of delight would be if the note input itself faded in (quickly, e.g. 0.1 or 0.2s speed), and didn't blink upon submission, perhaps simply resized itself as the input becomes text and the threading buttons below appear. Is that going to eventually be possible, and if yes, something worth tracking separately? |
Props to using sidebars; we get that animation for free.
I agree that a similar animation would be really nice. P.S. While visually it appears to be the same note, technically the component rebuilds the entire notes tree and renders the newly added note. I would probably file this into the "nice to haves" list. Pleaking of blinks. When clicking the "Add note" button, the form sometimes blinks to the top and then renders correctly. It's not a blocker; something would be nice to resolve in follow-up. Here, I had to throttle the CPU to make it somewhat visible in the screencast. CleanShot.2025-10-24.at.11.55.50.mp4 |
| ? // Delay showing the floating note box until a Y position is known to prevent blink. | ||
| { top: y, opacity: ! y ? 0 : undefined } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bit hacky, but fixes position blink - #72494 (comment).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we instead return null above (instead of the VStack) when y is unavailable and avoid rendering the component entirely?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried, but it messed up positioning and focus transfer. The null can't have references from floating UI, so we end up with a stale y value.
With this method, we at least get the correct position when it's available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, that won't work since we need the component to render to get its height which is used to calculate the y values.
🎉 Woohoo! Thanks for the review @jasmussen and for the refactoring @Mamaduka - I'll give this some further testing! |
Mamaduka
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's merge this. @t-hamano, do you have any concerns here?
|
Sorry for the late, checking the code and discussions now 👀 |
|
I pushed the following changes. f83dd68: I removed Removed unnecessary VStack components. This will fix some visual issues and layout problems.
|
t-hamano
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on my testing, it's working correctly 👍
I think we need to restore this. Otherwise, clicking inside the add new note element triggers CleanShot.2025-10-27.at.17.53.59.mp4 |
|
Thanks for the refinements here @t-hamano! |
|
This continues to work well in my testing, once the tests pass we can merge. |
…2494) * ove AddComment from index to Comments so it can float * try floating new new * remove debug logging * revert add-comments changes * try: add comment in floating thread * Ensure new comment inserted in correct thread index * fix floating thread issues * cleanup * reflow notes in the new note form * Fix note ordering on new note insertion * Reset refs when comment updated * Reselect the new note thread when block selection changes * Move VStack back inside add-comment to avoid double wrapping, reposition top text * Whitespace * Comments cleanup * Fix e2e test and cleanup * Hide the new note form onBlur * Fix new note position blink * whitespace * Remove unnecessary tabIndex from the new note form * Remove unnecessary wrapper * Restore tabindex and add aria-label text --------- Co-authored-by: George Mamadashvili <[email protected]> Co-authored-by: Aki Hamano <[email protected]>
|
I just cherry-picked this PR to the wp/6.9 branch to get it included in the next release: 2060336 |



What?
Closes #72444
Why?
In floating mode, align the "New Note" popup with the selected block.
How?
Testing Instructions
Testing Instructions for Keyboard
Same
Screenshots or screencast
pinned.new.note.1.mp4