-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Notes position alignment in HTML #73046
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
Notes position alignment in HTML #73046
Conversation
|
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. |
| // Track mode change for the selected block to reflow offsets on "Edit as HTML" | ||
| const blockMode = useBlockMode( selectedBlockClientId ); |
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.
We don't need a separate hook here. We can get block mode as part of existing useSelect on line 70, which is already subscribed to block editor store.
|
@Mamaduka — When you have a moment, could you please review this PR? I’d appreciate your feedback and insights on the recent changes. Thank you! |
roseg43
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.
@karthick-murugan I took a look at these changes and tested it out locally, and the issue appears to be fixed. 😄
|
@karthick-murugan, this is on my to-do list and I will review it properly when I've time. I'm also curious about what the root cause of this alignment shift is. When block editing mode changes, the block element reference remains untouched (at least in my tests); it's odd that the alignment is lost. |
|
@Mamaduka with most of the WP 6.9 RC polishing behind us, reminder ping on this PR to try and get to a resolution (whether in 6.9 or not) |
|
The changes look good here @karthick-murugan - nice work!
I also wonder why this is happening if the ref isn't changing. I'm going to spend some more time debugging that; regardless the fix would be fine to add. |
|
I spent some time debugging this and discovered that the ref does change when switching a block to HTML mode and back again. I could see this by console logging the ref, then clicking on it which would show a "missing node" error.
For one thing, the block looses its "rich-text" class. The fix in this PR is probably best, when I tried fixing it I wound up with nearly the same code except my code added another useSelect, so I think this PR is cleaner and we can move forward with this one. |
adamsilverstein
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.
Nice work!
|
@jeffpaul Since the Gutenberg sync for the RC3 release has already been performed, I don't think this PR can be shipped to 6.9.0 unless there is a special RC4. I think the earliest we can ship this PR is 6.9.1. |
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.
@karthick-murugan Just to be sure, can you rebase this PR on top of the trunk branch?
I wouldn't object to merging this PR, but I've identified several other scenarios where references get lost. See #73565
In any case, a more fundamental fix is needed.
119f67a to
796d0d6
Compare
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.
@karthick-murugan Thanks for the update! Let's ship this for now and work on investigating the root cause in a follow-up.
Additionally, I'm marking this PR as a potential backport candidate for 6.9.1.

What
Closes #72836
Fixes the issue where note positions in the floating Notes panel become misaligned after switching a block between “Edit as HTML” and Visual modes. The change ensures that notes remain properly aligned with their corresponding blocks during and after editing mode transitions.
Why?
When switching a block’s editing mode (Visual ↔ HTML), the notes sidebar incorrectly positions the affected notes at the top of the canvas until the page is refreshed.
This PR introduces a fix that reflows comment positions immediately after mode transitions, maintaining correct alignment without requiring a reload.
Testing Instructions
Video
REC-20251106165651.mp4