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

Template Part Block: Use buttons for area selection #30005

Closed
wants to merge 5 commits into from
Closed

Template Part Block: Use buttons for area selection #30005

wants to merge 5 commits into from

Conversation

creativecoder
Copy link
Contributor

@creativecoder creativecoder commented Mar 19, 2021

Description

Resolves #29295

How has this been tested?

  1. Open the site editor
  2. Select a template part block, such as the header (the list view is an easy way to do this).
  3. Open the Advanced section of the sidebar options and choose the area.

Screenshots

Template Part Block > Advanced settings in sidebar

image

image

Types of changes

New feature (non-breaking change which adds functionality)

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • I've tested my changes with keyboard and screen readers.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR.

@jameskoster
Copy link
Contributor

Looking good! :)

I updated the icon / description for the general area.

Screenshot 2021-03-19 at 09 24 33

The width of these tooltips makes them a little awkward to read. Is it possible to wrap them?

@creativecoder
Copy link
Contributor Author

I updated the icon / description for the general area.

Thank you!

The width of these tooltips makes them a little awkward to read. Is it possible to wrap them?

Yes! Now updated.

I'm a little unsure about the screen reader accessibility of using tooltips to describe the template part areas. I modified the Tooltip component to be able to receive an id and be the target of aria-describedby (declared on the buttons)--this seems to help when testing with VoiceOver, but I'd want a more experienced opinion before merging this.

@creativecoder creativecoder marked this pull request as ready for review March 19, 2021 19:32
@creativecoder creativecoder changed the title [WIP] Template Part Block: Use buttons for area selection Template Part Block: Use buttons for area selection Mar 19, 2021
position,
text,
shortcut,
...popoverProps
Copy link
Member

Choose a reason for hiding this comment

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

Hmmmm 🤔 This seems to be a rather big modification. I wonder if we should use an explicit popoverProps property instead of ... rest. We need to update the README too.

As a last thought, maybe we should move this to a separate PR?

@david-szabo97
Copy link
Member

It's working as expected. My only concern is the modification of the Tooltip component. The changes make sense but it feels it should be its own PR. Looking forward to others' thoughts.

Screen.Recording.2021-03-22.at.9.58.18.mov

@jameskoster
Copy link
Contributor

+1 to moving the a11y discussion to a separate issue since it will effectively relate to all tooltip usage across the app.

@david-szabo97
Copy link
Member

@creativecoder Could you break this into multiple PRs?

We should remove the tooltip changes from this PR and create a separate PR for just the tooltip. Then we can create a follow-up PR to add the accessibility parts once we have the tooltip PR merged. You can use the tooltip PR as a base for the follow-up PR so we can show a use-case as well in the tooltip PR.

So basically we will have 3 PRs in the end:

  1. This PR which introduces the buttons for area selection (without a11y in mind)
  2. Tooltip PR which adds the new prop to the Tooltip component so we can passthrough props to the Popover component
  3. A accessibility follow-up PR to the 1. one, using 2. as the base branch

@creativecoder
Copy link
Contributor Author

Could you break this into multiple PRs?

Yes! Will work on that soon. I'd like to leave the className passthrough (Tooltip prop that's passed to the Popover component) so we can control the tooltip width. That seems less invasive, and therefore okay? I'll be sure to update the component readme, accordingly.

@david-szabo97
Copy link
Member

I'd like to leave the className passthrough (Tooltip prop that's passed to the Popover component) so we can control the tooltip width. That seems less invasive, and therefore okay?

I would be still concerned about the PR's responsibility. In my opinion, it's better to avoid making core changes in a mostly Site Editor related PR. Smaller PRs and single responsibility PRs are easier to revert and discuss.

Copy link
Contributor

@Addison-Stavlo Addison-Stavlo left a comment

Choose a reason for hiding this comment

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

Just some minor thoughts, its lookin pretty good so far. 😁

value={ area }
onChange={ setArea }
/>
<BaseControl
Copy link
Contributor

@Addison-Stavlo Addison-Stavlo Apr 5, 2021

Choose a reason for hiding this comment

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

I wonder if RadioGroup/Radio components would be able to fit well and be adaptable for this case? It seems pretty similar visually and behaviorally to what we are going for.

Copy link
Member

Choose a reason for hiding this comment

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

+1 for RadioGroup and Radio components. They seem to fit this particular situation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the idea, I will take a look.

Comment on lines +23 to +28
description: __(
'The Header template defines a page area that typically contains a title, logo, and main navigation.'
),
icon: header,
label: __( 'Header' ),
value: 'header',
Copy link
Contributor

Choose a reason for hiding this comment

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

Not something that needs changed in this PR, but we should centralize these descriptions/definitions so we don't need to re-define them in a handful of places. I'm trying that as part of #30395, so a follow up once these both land would be to update this to get that data from the core editor store.

Copy link
Contributor

@jameskoster jameskoster left a comment

Choose a reason for hiding this comment

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

Approving the design. If the width has to be fixed in a follow-up PR, so be it :D

@david-szabo97
Copy link
Member

david-szabo97 commented Apr 30, 2021

👋 Would love to see this merged 😄 Could you rebase it? Happy to approve once tests are passing and rebased. We can create a follow-up PR for the a11y comment.

@creativecoder
Copy link
Contributor Author

Closing in favor of #45764, which uses the newer ToggleGroupControl component.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Template Part Affects the Template Parts Block
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Template part: Area selection UI
4 participants