close
Skip to content

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

Open
hbhalodia wants to merge 5 commits into
WordPress:trunkfrom
hbhalodia:feature/issue-72822
Open

Feature: Need to add “Show More” / “Show Less” toggle in Note.#77446
hbhalodia wants to merge 5 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
Copy link
Copy Markdown

github-actions Bot commented Apr 17, 2026

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 <hbhalodia@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: jameskoster <jameskoster@git.wordpress.org>
Co-authored-by: jeffpaul <jeffpaul@git.wordpress.org>
Co-authored-by: theminaldiwan <multidots1896@git.wordpress.org>

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

Copy link
Copy Markdown
Contributor

@t-hamano t-hamano left a comment

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
Copy link
Copy Markdown
Contributor

@t-hamano t-hamano left a comment

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
Copy link
Copy Markdown
Contributor

jasmussen commented May 13, 2026

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
Copy link
Copy Markdown
Contributor

jasmussen commented May 13, 2026

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

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

@ciampo
Copy link
Copy Markdown
Contributor

ciampo commented May 13, 2026

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
Copy link
Copy Markdown
Contributor

jameskoster commented May 14, 2026

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
Copy link
Copy Markdown
Contributor

ciampo commented May 14, 2026

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

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.

6 participants