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

Try/add page name to document settings [IN PROGRESS] #25386

Closed
wants to merge 13 commits into from

Conversation

jeyip
Copy link
Contributor

@jeyip jeyip commented Sep 16, 2020

Description

Addresses #25586

Document settings are being added to the site editor in the center of the block editor topbar. This PR adds content to the document settings dropdown, whereby the user can change the page title (if the page context exists).

How has this been tested?

Screenshots

Screen Shot 2020-09-16 at 3 33 58 PM

Types of changes

New feature

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • 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.

@jeyip jeyip added the [Status] In Progress Tracking issues with work in progress label Sep 16, 2020
@jeyip jeyip requested a review from youknowriad as a code owner September 16, 2020 22:14
@jeyip jeyip self-assigned this Sep 16, 2020
@jeyip jeyip force-pushed the try/add_page_name_to_document_settings branch from 147371b to 9e52497 Compare September 16, 2020 22:27
@github-actions
Copy link

github-actions bot commented Sep 16, 2020

Size Change: +338 B (0%)

Total Size: 1.2 MB

Filename Size Change
build/edit-site/index.js 19.6 kB +338 B (1%)
ℹ️ View Unchanged
Filename Size Change
build/a11y/index.js 1.14 kB 0 B
build/annotations/index.js 3.67 kB 0 B
build/api-fetch/index.js 3.41 kB 0 B
build/autop/index.js 2.83 kB 0 B
build/blob/index.js 620 B 0 B
build/block-directory/index.js 8.53 kB 0 B
build/block-directory/style-rtl.css 943 B 0 B
build/block-directory/style.css 942 B 0 B
build/block-editor/index.js 128 kB 0 B
build/block-editor/style-rtl.css 11 kB 0 B
build/block-editor/style.css 11 kB 0 B
build/block-library/editor-rtl.css 8.59 kB 0 B
build/block-library/editor.css 8.59 kB 0 B
build/block-library/index.js 135 kB 0 B
build/block-library/style-rtl.css 7.6 kB 0 B
build/block-library/style.css 7.59 kB 0 B
build/block-library/theme-rtl.css 741 B 0 B
build/block-library/theme.css 741 B 0 B
build/block-serialization-default-parser/index.js 1.88 kB 0 B
build/block-serialization-spec-parser/index.js 3.1 kB 0 B
build/blocks/index.js 47.8 kB 0 B
build/components/index.js 201 kB 0 B
build/components/style-rtl.css 15.5 kB 0 B
build/components/style.css 15.4 kB 0 B
build/compose/index.js 9.68 kB 0 B
build/core-data/index.js 12.2 kB 0 B
build/data-controls/index.js 1.28 kB 0 B
build/data/index.js 8.55 kB 0 B
build/date/index.js 31.9 kB 0 B
build/deprecated/index.js 772 B 0 B
build/dom-ready/index.js 568 B 0 B
build/dom/index.js 4.48 kB 0 B
build/edit-navigation/index.js 10.7 kB 0 B
build/edit-navigation/style-rtl.css 868 B 0 B
build/edit-navigation/style.css 871 B 0 B
build/edit-post/index.js 305 kB 0 B
build/edit-post/style-rtl.css 6.24 kB 0 B
build/edit-post/style.css 6.22 kB 0 B
build/edit-site/style-rtl.css 3.26 kB 0 B
build/edit-site/style.css 3.26 kB 0 B
build/edit-widgets/index.js 16.4 kB 0 B
build/edit-widgets/style-rtl.css 2.75 kB 0 B
build/edit-widgets/style.css 2.75 kB 0 B
build/editor/editor-styles-rtl.css 492 B 0 B
build/editor/editor-styles.css 493 B 0 B
build/editor/index.js 45.3 kB 0 B
build/editor/style-rtl.css 3.8 kB 0 B
build/editor/style.css 3.8 kB 0 B
build/element/index.js 4.65 kB 0 B
build/escape-html/index.js 733 B 0 B
build/format-library/index.js 7.71 kB 0 B
build/format-library/style-rtl.css 547 B 0 B
build/format-library/style.css 548 B 0 B
build/hooks/index.js 2.13 kB 0 B
build/html-entities/index.js 621 B 0 B
build/i18n/index.js 3.56 kB 0 B
build/is-shallow-equal/index.js 711 B 0 B
build/keyboard-shortcuts/index.js 2.52 kB 0 B
build/keycodes/index.js 1.94 kB 0 B
build/list-reusable-blocks/index.js 3.12 kB 0 B
build/list-reusable-blocks/style-rtl.css 476 B 0 B
build/list-reusable-blocks/style.css 476 B 0 B
build/media-utils/index.js 5.32 kB 0 B
build/notices/index.js 1.79 kB 0 B
build/nux/index.js 3.4 kB 0 B
build/nux/style-rtl.css 671 B 0 B
build/nux/style.css 668 B 0 B
build/plugins/index.js 2.56 kB 0 B
build/primitives/index.js 1.41 kB 0 B
build/priority-queue/index.js 789 B 0 B
build/redux-routine/index.js 2.85 kB 0 B
build/rich-text/index.js 13.9 kB 0 B
build/server-side-render/index.js 2.77 kB 0 B
build/shortcode/index.js 1.69 kB 0 B
build/token-list/index.js 1.27 kB 0 B
build/url/index.js 4.06 kB 0 B
build/viewport/index.js 1.85 kB 0 B
build/warning/index.js 1.14 kB 0 B
build/wordcount/index.js 1.17 kB 0 B

compressed-size-action

@ZebulanStanphill ZebulanStanphill added the Needs Accessibility Feedback Need input from accessibility label Sep 16, 2020
Copy link
Member

@ZebulanStanphill ZebulanStanphill left a comment

Choose a reason for hiding this comment

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

It's worth noting that I'm working on #25353, which serves a similar purpose and would probably conflict with this PR.

Comment on lines +74 to +90
<Button
onClick={ onToggle }
className={ classnames(
'edit-site-document-actions__label',
'edit-site-document-actions__title',
{
'is-active': isTitleActive,
}
) }
aria-haspopup="true"
aria-expanded={ isOpen }
onKeyDown={ openOnArrowDown }
label={ __( 'Change document settings.' ) }
showTooltip
>
{ documentTitle }
</Button>
Copy link
Member

Choose a reason for hiding this comment

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

I don't think the label attribute works if you also have a nested text label. Additionally, it is an accessibility anti-pattern (i.e. something you should avoid) to use current state to label a button. The visible label should just be what's in the label attribute right now.

Also, you might be able to shorten the label to just "Document settings".

Copy link
Contributor

@Addison-Stavlo Addison-Stavlo Sep 16, 2020

Choose a reason for hiding this comment

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

Additionally, it is an accessibility anti-pattern to use current state to label a button. The visible label should just be what's in the label attribute right now.

An aria-label should override any button text regarding accessibility. The visible text should be fine as a basic name as long as we aria-label with the action?

Copy link
Member

Choose a reason for hiding this comment

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

ARIA attributes are supposed to be a last resort, not a band-aid to let one give any visible label to a button and call it accessible. A <button> should, if at all possible, use a visible text label that actually functions as a label. Accessibility doesn't just apply to screen readers; it applies to all methods of interaction.

While the efforts towards accessibility have been significant, there has been a strong dependence on methods we consider to be anti-patterns. First among these is a heavy use of ARIA attributes. ARIA, while sometimes necessary, should be considered only as a final option when no native HTML interactions are available.

This reflects a problem in the design process: beginning with custom controls (such as the “switch toggle”), then attempting to make them accessible rather than beginning with standard controls and making a functional interface.

https://make.wordpress.org/accessibility/2018/10/29/report-on-the-accessibility-status-of-gutenberg/

The accessibility team has wanted issues like #470 to be fixed for over 3 years now. Only now is it looking like that particular issue will be resolved. (See #25170 and #24024.) We shouldn't be introducing more buttons that have the same problem but even less of a reason to not use a proper label.

Copy link
Contributor

Choose a reason for hiding this comment

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

An aria-label should override any button text regarding accessibility. The visible text should be fine as a basic name as long as we aria-label with the action?

@Addison-Stavlo as I just explained on #25085 (comment) a mismatch between the visible text and the aria-label is a huge barrier for some users and violates WCAG Label in Name.

Also, totally agree with @ZebulanStanphill that ARIA should be used as last resort and also in that case should be used appropriately. Always prefer meaningful visible text, please.

Also, since the underlying issue in #470 is being discussed since more than 3 years now, I'd expect designers and developers in this project to be aware of that and to share information when new designers / developers join the project, otherwise repeating over and over the same recommendation is going to be unsustainable for the accessibility team. I do realize this part is more related to process but, alas, it appears the process has big room for improvements.

Copy link
Contributor

@Addison-Stavlo Addison-Stavlo Sep 17, 2020

Choose a reason for hiding this comment

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

Thanks for the insight, and thank you for the explanation there on that issue @afercia. It is definitely helpful.

I think a large barrier we run into that makes naming buttons after their actions difficult is the available real estate in the areas they need to go. For example in the available room in this top bar can be extremely limited in tablet/mobile views as well as with the top-toolbar mode activated. So much so we can't afford to put Template / Template Part names side by side and need to stack them vertically, and something likeOpen Template: ${template_name}'s settings or something similar would not be an option here either. With limited room, how do we go about adding more interactions while still making them accessible to all accessibility flows? 🤔 (I don't expect an explicit answer, this is just something I am trying to ponder as I learn more about accessibility)

Copy link
Member

Choose a reason for hiding this comment

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

I'd expect designers and developers in this project to be aware of that and to share information when new designers / developers join the project, otherwise repeating over and over the same recommendation is going to be unsustainable for the accessibility team.

I totally get the frustration here. :) I think this probably applies to so many things across the block editor. For example, a specific data store might cache data in a very specific way for performance reasons, but a new developer to the project won't understand that context. So they could easily make a change which circumvents that caching, causing a performance regression. (That's me, I made a change like that!)

I don't think there is really any sort of onboarding process at all for new devs, other than reading the documentation and code (which is fairly poor, unfortunately.) I wonder if there is a sustainable way to share this information, since I imagine there are a lot of similar examples. 🤔 Because that would definitely be great for both you and me in this situation! I think at least partially, some of these issues are just an ongoing learning process for everyone.

Part of that is Gutenberg contributions are really accessible to a broad range of folks: it doesn't require much of anything to start trying to contribute. So there are lots of contributors with varying ranges of experience on different topics, which means we don't really have that shared base of common skills or knowledge. :/ Which goes back into what you said: would it be helpful to create a way to generate a baseline of knowledge for new contributors? ANYWays, we're getting pretty meta here. :p

I think the space issue @Addison-Stavlo mentions is going back to the root designs we are working with here. I know that y'all have brought up this topic tons of times in the discussions about these designs. Point being, it'd be really nice to all get on the same page about how exactly this is going to work, rather than splitting this discussion across several issues.

And part of that being, we're exploring and creating some prototypes for what these might look like, so I don't think we have to treat this PR as if we are trying to do something outside of the discussion so far. We're very happy to incorporate improvements that we reach consensus on! I think in this case, it is difficult as a dev to incorporate improvements if we aren't completely sure what this interaction should look like after all of the suggestions are in place. 🤔 I basically don't want to get into a place where we implement X, and which you disagree on, so we implement Y, which design disagrees on, etc.

Copy link
Member

Choose a reason for hiding this comment

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

I think part of the problem here is that you're trying to conflate two things that should be separate: an indicator of the current template title, and a button to change the template's title/url/etc. Trying to have one UI element serve as both probably won't work.

The purpose of the template settings button is to open an interface to edit the template settings. So it should be labeled accordingly, and it's position in the UI would logically be somewhere in the top bar.

The indicator of the current template's title, however, is something different. And I don't think it belongs in the top bar... at least not in the same row as everything else. It's already weird that there's a left half and a right half to the top bar. I think adding a middle section would just confuse the layout even more.

I think what we're looking for is a sort of "status bar". Something that is designed to present information to the user first and foremost, with any interactivity being a "nice to have" that isn't treated as the primary way to do anything.

Maybe this bar could look something like this:

Inside template part: Header  |  Selected block: Paragraph  |  Visibility: Public  |  Publish date: Dec 12, 2020

Perhaps this status bar could be placed below the top bar or maybe even above it. Maybe it could take the place of the current footer bar? I'm not sure.

I also had another idea for presenting "status" info, which I'll quote from #25353 (comment):

Maybe we ought to consider adding a "document status/overview" popover/modal/something that lists out important details of the document (e.g. visibility, publish state, SEO status), with "Edit" links to jump to the parts of the UI dedicated to changing those details. Maybe we could even combine it with the "Content structure" tool (the one that shows word count and stuff like that)? Just throwing ideas out there.

Copy link
Contributor

Choose a reason for hiding this comment

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

And I don't think it belongs in the top bar...

I think you have some good ideas, but I will note that #25085 specifically for exposing these names in the top bar has been generally agreed upon and added to the next phase of the Site Editors infrastructure development #24818 . We are just moving forward with that infrastructure and UI development agenda.

I do welcome your concerns and ideas, however this PR may not be the best place to raise concerns with whether or not we should show the names here or in a new status bar, as most of the eyes involved in that consensus and decision may not see them. Nothing is final and even if we (together as core) move forward to put the labels in this region, we are still able to discuss better solutions and reiterate. But for now, there needs to be a starting point to assess and start iterating from and putting them here seems to be the current consensus for that starting point.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @Addison-Stavlo !

I think a large barrier we run into that makes naming buttons after their actions difficult is the available real estate in the areas they need to go.

Well, generally any UI should be designed around the content, not the other way around 🙂 Trying to "squeeze" controls and text into a limited space is a clear sign the UI has some problems in the first place. I do realize this feedback doesn't propose an alternative solution. Maybe, some lateral thinking could help and i fit was up to me I'd ask myself whether the top bar is really the right place for these control. Giving all the problems we're facing, I'd say it is not.

Comment on lines 47 to 50
const { page } = useSelect( ( select ) => {
const { getPage } = select( 'core/edit-site' );
return { page: getPage() };
} );
Copy link
Member

Choose a reason for hiding this comment

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

If you're just going to get one thing from useSelect, you can simplify this and avoid any destructuring.

Suggested change
const { page } = useSelect( ( select ) => {
const { getPage } = select( 'core/edit-site' );
return { page: getPage() };
} );
const page = useSelect( ( select ) => select( 'core/edit-site' ).getPage() );

@noahtallen
Copy link
Member

which serves a similar purpose and would probably conflict with this PR.

Given that there are no document settings in the site editor yet, I think we won't conflict for now. 😅

One could see a future where this item in the header opens a document settings dialogue modal, if that is indeed the interaction we move towards for document settings.

For the time being, in the site editor, we are exploring the specific items which ought to make up document settings in the context of multiple entities (starting with the basics). I believe it has been mentioned in some other issues that with the site editor, we get an opportunity to improve the hierarchy and design of these settings, so we currently plan to move towards that incrementally from the FSE side of things.

);
} }
renderContent={ () => (
<div
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be helpful to split out the actual settings area into a separate component, even at this early stage :) (including the page selector above)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Totally agreed 👍

@jeyip jeyip marked this pull request as draft September 16, 2020 23:40
@jeyip jeyip force-pushed the try/add_page_name_to_document_settings branch from e5bb192 to be81066 Compare September 17, 2020 17:36
@noahtallen noahtallen force-pushed the try/add-document-settings-in-header branch from 202d122 to f4927d4 Compare September 17, 2020 22:04
Base automatically changed from try/add-document-settings-in-header to master September 17, 2020 23:20
Comment on lines +114 to +116
<span style={ { marginRight: '12px' } }>
Name
</span>
Copy link
Member

Choose a reason for hiding this comment

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

This should be a <label> associated via the for prop with the <input> that follows it. You can use useInstanceId to help make a unique id for the <input>.

Copy link
Contributor Author

@jeyip jeyip Sep 21, 2020

Choose a reason for hiding this comment

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

Thanks @ZebulanStanphill I'm still working on the main functionality of the PR, but I'll be sure to circle back and address this too before the next cycle of code review 👍

@jeyip
Copy link
Contributor Author

jeyip commented Sep 28, 2020

Thanks for the staying involved in this PR everyone! We will not be making page name and page slug editable in the site editor for now. We can return to this whenever "template editing" is better developed.

@jeyip jeyip closed this Sep 28, 2020
@aristath aristath deleted the try/add_page_name_to_document_settings branch November 10, 2020 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Accessibility Feedback Need input from accessibility [Status] In Progress Tracking issues with work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants