Skip to content
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

Placeholder component: Replace upload icon with text when rendering labels #44437

Open
wants to merge 15 commits into
base: trunk
Choose a base branch
from

Conversation

RahiDroid
Copy link
Contributor

@RahiDroid RahiDroid commented Sep 25, 2022

What?

  • Renders the text label instead of the upload icon for the Placeholder component when the Show button text labels preference is enabled.
  • Fixes a minor UI issue with the block mover when labels are enabled.
  • Reduces specificity for the Featured image block's styles so that it can be overwritten when labels are to be rendered for the placeholder. This change overlaps with a change in Post Featured Image: Fix borders after addition of overlay feature #44286, but is required for this PR as well. Credit to the PR author.

Why?

How?

Testing Instructions

Since this PR touches a couple of widely used components' styles, it should be tested thoroughly.

  1. Open the post editor.
  2. Go to Options > Preferences > General and enable Show button text labels. See this comment for visuals of this option.
  3. Insert a Post Featured Image block.
  4. Move your focus on the block by clicking on it if you don't see any button or block controls for it.
  5. You should see a button with the label Add a featured image instead of the circular upload button.

Screenshots or screencast

Before After
Screenshot 2022-09-25 at 9 41 04 PM Screenshot 2022-09-29 at 4 06 35 AM
Screenshot 2022-09-26 at 1 38 44 AM Screenshot 2022-09-29 at 4 07 59 AM

This reduction also helps us ensure the labels are shown instea of the
icon when 'Show button labels' preference is enabled.
@Mamaduka Mamaduka requested a review from jasmussen September 26, 2022 05:31
@jasmussen
Copy link
Contributor

Nice, that makes good sense! Can the label be generic, just "Add"? Or even "Add media"?

@RahiDroid
Copy link
Contributor Author

RahiDroid commented Sep 26, 2022

Nice, that makes good sense! Can the label be generic, just "Add"? Or even "Add media"?

Thank you for checking @jasmussen! This line ensures that whatever is passed in the aria-label attribute, which is the label prop on the Button component gets used as the text/label. Do you suggest we add a fallback to the Button component in case we don't get passed the label attribute? I don't think a Button will be able to has a default/generic label. Or were you referring to any other label?

@jasmussen
Copy link
Contributor

Can we just change the aria-label to be "Add" or "Add media"? Mainly it's a question of fitting in constrained contexts, which is more likely to be possible with shorter phrases. Otherwise could we have the button use a regular label and have the aria label as a tooltip?

@RahiDroid
Copy link
Contributor Author

RahiDroid commented Sep 26, 2022

@jasmussen Understood. I have shortened the button labels to be Add media which I believe is bit more descriptive compared to only Add and would make more sense for users using screen readers. The Button component currently uses the describedBy prop as the Tooltip and falls back to the label if it's not there. So I think we can let that logic be that way.

Here's what I am seeing after the change,
Screenshot 2022-09-26 at 4 47 49 PM

@jasmussen
Copy link
Contributor

That seems like a good starting point to me.

In general we are challenged with space, there's no getting around that, and I would love a full iteration on how we can improve the "labels only" mode in a cohesive way. Not saying that to block this one, just noting that I'd love to see an experiene as refined as the MacOS Finder "labels only" mode, for example, which seems more considered than what we have today.

For this PR, though, seems like it mainly needs a code review.

@joedolson
Copy link
Contributor

Should this be 'Add Image' instead of 'Add Media'? In these two contexts, as far as I know, we only support image assets, so I think that the greater specificity is advantageous. Otherwise, changes look good to me!

@RahiDroid
Copy link
Contributor Author

Should this be 'Add Image' instead of 'Add Media'? In these two contexts, as far as I know, we only support image assets, so I think that the greater specificity is advantageous. Otherwise, changes look good to me!

Yup, totally agree on that. I have made that change, updated the screenshots in the PR description, and have updated my branch.

Thank you for looking into it. @joedolson you can proceed with the re-review of the code.

@RahiDroid
Copy link
Contributor Author

Just a note for reviewers: The failing tests don't seem to be related to this PR.

@RahiDroid
Copy link
Contributor Author

Hi @joedolson @jasmussen 👋

Could you please help me with a review on this one? Or guide me if there's anything the PR needs.

@joedolson
Copy link
Contributor

I think it looks good as far as accessibility concerns go; I appreciate your handling the move up/move down alignment issues, as well. Code review will need to come from somebody with write access to the repository, but I can definitely give my thumbs up on the UI changes.

@RahiDroid
Copy link
Contributor Author

@mikachan!! I need your help (yet again 🙈). Could you please help me know who could code review this PR?

@mikachan mikachan added [Block] Post Featured Image Affects the Post Featured Image Block [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). labels Oct 5, 2022
@mikachan mikachan requested a review from carolinan October 5, 2022 15:55
@carolinan
Copy link
Contributor

@RahiDroid Hi, are you able to solve the merge conflict and rebase the PR?

@carolinan carolinan self-assigned this Jan 2, 2023
@RahiDroid
Copy link
Contributor Author

Hi @carolinan, I'll look into this after few hours. Busy with work at the moment.

@RahiDroid
Copy link
Contributor Author

RahiDroid commented Jan 2, 2023

@carolinan It appears that the blocks are being rendered inside an iframe, Editor canvas. And the class show-icon-labels gets added outside that iframe, and hence the styles don't affect the content part of the blocks any more. (It used to, previously)

If you go to that iframe and maybe add the class show-icon-labels on the body, you'll see the labels show up instead of the icons; when the preference is set to see labels.

Do you have any insights on this? Have there been any changes related to this lately? It would help me dig this further.

Edit: I have updated the branch with latest trunk if you wish to take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Post Featured Image Affects the Post Featured Image Block [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants