-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Notes: Don't hide floating sidebar while adding the note #72968
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
|
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. |
| // Enum: 'closed' | 'creating' | 'open' | ||
| const [ showCommentBoard, setShowCommentBoard ] = useState( 'closed' ); |
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 should probably rename this into something more appropicate.
const [ newNoteFormState, setNewNoteFormState ] = useState( 'closed' );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.
Should I rename the state and setter before we merge this, or should we keep the old naming for now? WDYT?
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.
Since the meaning of the state has changed, I think it's okay to rename it.
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.
Updated in 6d52b7b.
|
Size Change: +17 B (0%) Total Size: 2.45 MB
ℹ️ View Unchanged
|
|
Flaky tests detected in 6d52b7b. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/19102337868
|
| : threadSelector; | ||
|
|
||
| return new Promise( ( resolve ) => { | ||
| // Watch the sidebar skeleton in case the sidebar disappears and re-appears. |
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!
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, I like how the original observer code works now
|
I've retested and I think this is good to go. Tententively labeling it for backporting. There's also one open question - #72968 (comment). |
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.
I may have missed something, but it seems the problem can also be solved by making the following changes to the trunk branch without using enum states. What do you think?
diff --git a/packages/editor/src/components/collab-sidebar/add-comment.js b/packages/editor/src/components/collab-sidebar/add-comment.js
index 44f5145bb1..94cfd618e5 100644
--- a/packages/editor/src/components/collab-sidebar/add-comment.js
+++ b/packages/editor/src/components/collab-sidebar/add-comment.js
@@ -91,7 +91,7 @@ export function AddComment( {
onSubmit={ async ( inputComment ) => {
const { id } = await onSubmit( { content: inputComment } );
focusCommentThread( id, commentSidebarRef.current );
- setShowCommentBoard( false );
+ setShowCommentBoard( true );
} }
onCancel={ unselectThread }
reflowComments={ reflowComments }
diff --git a/packages/editor/src/components/collab-sidebar/utils.js b/packages/editor/src/components/collab-sidebar/utils.js
index 6e52a6c94a..dd5a29513a 100644
--- a/packages/editor/src/components/collab-sidebar/utils.js
+++ b/packages/editor/src/components/collab-sidebar/utils.js
@@ -99,15 +99,11 @@ export function getCommentExcerpt( text, excerptLength = 10 ) {
* @typedef {import('@wordpress/element').RefObject} RefObject
*
* @param {string} commentId The ID of the comment thread to focus.
- * @param {?HTMLElement} threadContainer The container element to search within.
+ * @param {?HTMLElement} container The container element to search within.
* @param {string} additionalSelector The additional selector to focus on.
*/
-export function focusCommentThread(
- commentId,
- threadContainer,
- additionalSelector
-) {
- if ( ! threadContainer ) {
+export function focusCommentThread( commentId, container, additionalSelector ) {
+ if ( ! container ) {
return;
}
@@ -120,11 +116,6 @@ export function focusCommentThread(
: threadSelector;
return new Promise( ( resolve ) => {
- // Watch the sidebar skeleton in case the sidebar disappears and re-appears.
- const container = threadContainer.closest(
- '.interface-interface-skeleton__sidebar'
- );
-
if ( container.querySelector( selector ) ) {
return resolve( container.querySelector( selector ) );
}|
I haven’t tested it, but I think in that case, if you select a block without a note after creating a new one, the “Add note” will reappear. P.S. Enums are great for communicating complex states. Screencast from testingCleanShot.2025-11-05.at.15.29.23.mp4 |
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.
I haven’t tested it, but I think in that case, if you select a block without a note after creating a new one, the “Add note” will reappear.
You're right, it certainly wasn't an ideal approach.
ff0f2b7 to
6d52b7b
Compare
|
I'm going to merge this; hopefully, the large renaming won't cause major backporting issues. |
* Notes: Don't hide floating sidebar while adding the note * Revert focusCommentThread changes * Rename state and it's setter Co-authored-by: Mamaduka <[email protected]> Co-authored-by: adamsilverstein <[email protected]> Co-authored-by: t-hamano <[email protected]>
|
I just cherry-picked this PR to the wp/6.9 branch to get it included in the next release: face7ad |
What?
Related #72872 (comment).
PR fixes an issue that occurs when floating sidebars are closed and reopened while adding the first note. The problem is more visible if working slow networks.
How?
Switch
showCommentBoardto use enum state instead of boolean.Testing Instructions
Testing Instructions for Keyboard
Same
Screenshots or screencast
Examples are with Network > Slow 4G.
Before
CleanShot.2025-11-04.at.15.17.48.mp4
After
CleanShot.2025-11-04.at.15.08.44.mp4