Skip to content

Feature: Need to add “Show More” / “Show Less” toggle in Note.#77446

Merged
t-hamano merged 11 commits into
WordPress:trunkfrom
hbhalodia:feature/issue-72822
Jun 15, 2026
Merged

Feature: Need to add “Show More” / “Show Less” toggle in Note.#77446
t-hamano merged 11 commits into
WordPress:trunkfrom
hbhalodia:feature/issue-72822

Conversation

@hbhalodia

Copy link
Copy Markdown
Contributor

What?

Closes #72822

Why?

  • Adds the feature to collapse the long notes and show a button called, show more and show less exactly as how google docs commenting works for larger notes.

How?

  • Adds the state and effect to check for the comment length and add the button.
  • Based on the button click, it shows the full comment or hide the same.

Testing Instructions

  1. Go to any post/page.
  2. Insert a block and add a note with more text.
  3. Check the button for show more and show less, it should work as expected.

Testing Instructions for Keyboard

  • The button should work with keyboard navigation, and functionality should work as expected.

Screenshots or screencast

Screen.Recording.2026-04-17.at.3.13.53.PM.mov

Use of AI Tools

  • Claude Code.
  • Model - Claude Sonnet 4.6
  • Asked AI to review and issue and provide a quick and easy solution.
  • Have reviewed the code generated and looks good, Some more review needed and we can land this PR.

@hbhalodia hbhalodia requested a review from t-hamano April 17, 2026 09:44
@hbhalodia hbhalodia self-assigned this Apr 17, 2026
@hbhalodia hbhalodia added [Type] Enhancement A suggestion for improvement. [Feature] Notes Phase 3 of the Gutenberg roadmap around block commenting labels Apr 17, 2026
@github-actions github-actions Bot added the [Package] Editor /packages/editor label Apr 17, 2026
Comment thread packages/editor/src/components/collab-sidebar/comments.js Outdated
Comment thread packages/editor/src/components/collab-sidebar/comments.js Outdated
@t-hamano t-hamano requested review from a team, Mamaduka and adamsilverstein April 17, 2026 11:05
@github-actions

github-actions Bot commented Apr 17, 2026

Copy link
Copy Markdown

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: hbhalodia <[email protected]>
Co-authored-by: t-hamano <[email protected]>
Co-authored-by: adamsilverstein <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: jasmussen <[email protected]>
Co-authored-by: ciampo <[email protected]>
Co-authored-by: jameskoster <[email protected]>
Co-authored-by: jeffpaul <[email protected]>
Co-authored-by: theminaldiwan <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@t-hamano t-hamano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update!

There is one more point to correct. This button should not be displayed when editing a note.

Image

@hbhalodia

Copy link
Copy Markdown
Contributor Author

Thanks @t-hamano For the review.

Further, I have handled some more of edgecase. The overall functionality is like below,

  1. If the note is large on initial render, it will be collapsed and will have Show more button.
  2. If the note is small on initial render, it would not have any button.
  3. When editing a note, despite of user's previous state, it would always would be uncollapsed mode (as user edited the note, so we should show them edited version in full), and would have button show less to make it collapsed.
  4. No button is shown while editing the note.
  5. When edited, if the note content is small, the button would not be shown.

Let me know if there are any other edge cases needs to be handled, I guess most of them are covered.

Thanks,

@hbhalodia hbhalodia requested a review from t-hamano April 20, 2026 06:06
@t-hamano t-hamano requested a review from a team April 20, 2026 13:51

@t-hamano t-hamano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR works well for me.

@Mamaduka @adamsilverstein, Are there any better approaches besides using element.scrollHeight > element.clientHeight to detect element overflow and display a button?

Comment thread packages/editor/src/components/collab-sidebar/comments.js Outdated
@Mamaduka

Copy link
Copy Markdown
Member

@t-hamano, I'll try to do a proper review later. I think some of the logic can be simplified/derived. But without design feedback, I think final reviews are low priority, since we're not sure what the end product will be.

@t-hamano t-hamano requested a review from a team April 21, 2026 08:13
@t-hamano t-hamano added the Needs Design Feedback Needs general design feedback. label Apr 21, 2026
@jasmussen

jasmussen commented May 13, 2026

Copy link
Copy Markdown
Contributor

Nice work! Good feedback has already been given, worth following.

Some of the nuance embedded in this is: we have this design to consider:

image

But this button is not the same. This button is for when a single comment note is very long and complicated. In that sense, the PR feels fairly close. Here's a quick sketch:

Frame 3

Some subtle differences to the PR:

  • Small button
  • Sentence case: "Show more" and "Show less", not "Show More" and "Show Less"

An awkward detail is that the tertiary button has left/right padding. The above mockup does not. So the text inside the button will not align with the text of the note. Probably this is fine?

@jasmussen

jasmussen commented May 13, 2026

Copy link
Copy Markdown
Contributor

Unless there's a true "text only" button we can use? CC: @ciampo

Edit: "Link" from @wordpress/ui might do it: #77743 (comment)

@ciampo

ciampo commented May 13, 2026

Copy link
Copy Markdown
Contributor

Link and Button represent different semantics, and should be used interchangably — if I understand correctly from the screenshots, we need button semantics but the Button component doesn't expose a variant that matches those styles? What about the minimal variant?

cc @mirka and @jameskoster , and also mentioning #77098 as likely related.

@jameskoster

jameskoster commented May 14, 2026

Copy link
Copy Markdown
Contributor

Unless the element triggers a url change I agree this should be a button. I think this is the kind of scenario we added the Unstyled variant for. That way we can make the entire 'row' (including the strokes) interactive for a larger click target. Edit: I realised I was looking at the '3 more replies' element 🙈

@ciampo

ciampo commented May 14, 2026

Copy link
Copy Markdown
Contributor

Unless the element triggers a url change I agree this should be a button. I think this is the kind of scenario we added the Unstyled variant for. That way we can make the entire 'row' (including the strokes) interactive for a larger click target.

Yes, we could try the unstyled variant + using:

  • for the text color, --wpds-color-fg-interactive-brand for resting state (plus --wpds-color-fg-interactive-brand-active for hover/focus/active, --wpds-color-fg-interactive-neutral-disabled when disabeld)
  • for typography:
    • either various --wpds-typography-* DS tokens
    • or the Text component

@t-hamano

t-hamano commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

@hbhalodia, do you have the bandwidth to resolve the code conflicts and address the feedback?

@hbhalodia

Copy link
Copy Markdown
Contributor Author

Hi @t-hamano, Thanks for the ping!

Yes I have some bandwidth today. I will resolve the conflicts and address the feedbacks to use the unstyled variant of the button as mentioned here - #77446 (comment)

Apologies on getting this missed!

Comment thread packages/editor/src/components/collab-sidebar/note.js
@hbhalodia hbhalodia requested a review from t-hamano June 8, 2026 09:22
@t-hamano

t-hamano commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

@hbhalodia Thanks for the update.

This PR is working well and appears to be ready for release from my end.

@jasmussen @Mamaduka Do you have any feedback?

@jasmussen

Copy link
Copy Markdown
Contributor

Looks good to me! Nice work.

state

@adamsilverstein

adamsilverstein commented Jun 14, 2026

Copy link
Copy Markdown
Member

I love the idea of this enhancement and the code looks fine, but in my local testing I couldn't get it working correctly (running Gutenberg and WordPress trunk). Maybe I am missing something, I'll give it a shot agains 7.0 as well.

@adamsilverstein adamsilverstein left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code looks good, but I didn't see the more/less feature in my testing for some reason.

@adamsilverstein

Copy link
Copy Markdown
Member

code looks good, but I didn't see the more/less feature in my testing for some reason.

It would be great to add some e2e tests or storybook story to verify this works as expected...

Comment thread packages/editor/src/components/collab-sidebar/style.scss Outdated
@adamsilverstein

Copy link
Copy Markdown
Member

code looks good, but I didn't see the more/less feature in my testing for some reason.

this was user error, its working for me now.

@hbhalodia

Copy link
Copy Markdown
Contributor Author

Hi @t-hamano, I have fixed the deprecated tokens and used the new ones. We can forward this PR.

Thanks,

@t-hamano t-hamano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@t-hamano t-hamano merged commit fda9287 into WordPress:trunk Jun 15, 2026
41 of 42 checks passed
@github-actions github-actions Bot added this to the Gutenberg 23.5 milestone Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Notes Phase 3 of the Gutenberg roadmap around block commenting Needs Design Feedback Needs general design feedback. [Package] Editor /packages/editor [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Need to add “Show More” / “Show Less” toggle in Note.

7 participants