-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
DataViews: make it the root for pages and add details #57578
Conversation
Size Change: +600 B (0%) Total Size: 1.69 MB
ℹ️ View Unchanged
|
packages/dataviews/src/view-list.js
Outdated
@@ -89,6 +93,19 @@ export default function ViewList( { | |||
</div> | |||
</VStack> | |||
</HStack> | |||
{ onDetailsChange && ( | |||
<Button |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm looking at how to make this button appear visually within the other interactive element (<div role="button">
) while avoid nesting in the DOM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I played with the idea of having two buttons: one nested and hidden from the accessibility tree, the second not nested and visually hidden.
It works, as demonstrated in the accessibility tree. Though, I'm not super keen on this idea:
Gravacao.do.ecra.2024-01-05.as.12.23.16.mov
In terms of code, something along these lines could work. It'd need factoring into a single component.
diff --git a/packages/dataviews/src/style.scss b/packages/dataviews/src/style.scss
index 93926db47d..72037da3d6 100644
--- a/packages/dataviews/src/style.scss
+++ b/packages/dataviews/src/style.scss
@@ -280,6 +280,16 @@
.dataviews-list-view__details-button {
align-self: center;
}
+ .dataviews-list-view__details-button-visually-hidden {
+ position: absolute;
+ width: 1px;
+ height: 1px;
+ margin: -1px;
+ padding: 0;
+ overflow: hidden;
+ clip: rect(0, 0, 0, 0);
+ border: 0;
+ }
}
.dataviews-action-modal {
diff --git a/packages/dataviews/src/view-list.js b/packages/dataviews/src/view-list.js
index cf9ca31851..ccfc821956 100644
--- a/packages/dataviews/src/view-list.js
+++ b/packages/dataviews/src/view-list.js
@@ -95,6 +95,7 @@ export default function ViewList( {
</HStack>
{ onDetailsChange && (
<Button
+ aria-hidden={true}
className="dataviews-list-view__details-button"
onClick={ () =>
onDetailsChange( [ item ] )
@@ -108,6 +109,19 @@ export default function ViewList( {
) }
</HStack>
</div>
+ { onDetailsChange && (
+ <Button
+ className="dataviews-list-view__details-button-visually-hidden"
+ onClick={ () =>
+ onDetailsChange( [ item ] )
+ }
+ icon={
+ isRTL() ? chevronLeft : chevronRight
+ }
+ label={ __( 'View details' ) }
+ size="compact"
+ />
+ ) }
</li>
);
} ) }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've also played with them being siblings within the same HStack. Tried different approaches, but wasn't able to make the first interactive element take all the space up to the second. There's always a weird gap.
Even if we were able to remove that gap and the button take the full height, visually, they will appear as two consecutive elements (see focus). Would that be a fine trade-off design-wise @jameskoster ?
Gravacao.do.ecra.2024-01-05.as.12.30.28.mov
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of duplicating 'details' buttons, could the main button and details button be adjacent, with the latter positioned absolutely? Something like this codepen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related, if the entire element is going to be a button, we'll have to be a bit more conscious of what the accessible names look like. By default, it's the text content of the control, which right now would probably be something like "Sample Page admin published", which isn't great. The best way to fix this would probably be by setting aria-labelledby
to point at the primaryField
content.
That being said, the main job of an accessible name is to convey the purpose or intent of the element, and just using the primary field value doesn't really do that. So we'll have to think a bit about the semantics around this; a straight-up list of buttons might not actually be the best model here anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain the benefit of doing this a bit more?
For sighted users the visual noise of the constantly-visible chevron is a bit distracting. It feels overly prominent in the UI. Perhaps a bad example but I'd liken it to tabs in a web/file browser, IDE, etc., where the close
button is generally not permanently visible.
If the overlapping button is going to be problematic perhaps we can try a different hover/focus treatment of the main button. I'll try a design iteration tomorrow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andrewhayward it occurred to me that the pattern I'm describing here is virtually identical to List View in the Editor. While not perfect, it has been quite rigorously tested. Do you think that since there's a precedent we might mimic that pattern here?
Edit: To be clear, the visuals still likely need some adjustment, particularly the hover state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's what I have:
Gravacao.do.ecra.2024-01-08.as.17.55.12.mov
Implemented it following the block editor list view pattern:
- structurally, buttons are siblings
- most styles are handled by the button's wrapper
- the focus styles are attached to a
::after
pseudo-element
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at how the block editor list view works from a keyboard perspective, a follow-up to this PR could be to make dataviews' list view work the same: tab only stops at the top-most item of the list layout, people use arrow keys to navigate through the items and accessing the details.
Related PR about making pages-dataviews the default for the "Pages" section: #57589 |
ecc4ebd
to
a75d5ab
Compare
Trying to land this iteratively was creating some weird interim flow experiences, so implemented the main flows here: Gravacao.do.ecra.2024-01-05.as.14.15.46.mov |
packages/edit-site/src/components/sidebar-navigation-screen-main/index.js
Outdated
Show resolved
Hide resolved
8dc94c6
to
1ad99df
Compare
@oandregal I just pushed some style tweaks. One thing I couldn't fix was the display of the preview, title, and fields – they're still quite a bit different to trunk:
I'm not fully convinced about the |
3d19480
to
8096b52
Compare
This is the current state: Gravacao.do.ecra.2024-01-09.as.09.34.31.mov@jameskoster is there any other design/interaction feedback you want incorporated in this PR? I'm looking now at other feedback and hoping to land this soon to unblock follow-ups. |
) } | ||
</div> | ||
<HStack> | ||
<li |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes here are to accommodate the two buttons as siblings. This is what we want:
<ul>
<li>
<div role="button">...</div> <!-- CONTENTS -->
<button /> <!-- DETAILS BUTTON -->
</li>
</ul>
Then, in CSS, we make it look like the first button (contents) wraps the second in situations such as focus. See accessibility conversation.
&:focus { | ||
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color); | ||
&::before { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pseudo-element serves to visualize the focus ring as it was part of the parent node (.dataviews-list-view__wrapper
). See conversation.
8096b52
to
537e399
Compare
One thing that could use a refinement is the focus styles for the details button when the item is selected (cc @jameskoster): Gravacao.do.ecra.2024-01-09.as.11.06.39.mov |
I just pushed a fix for this. |
OPERATOR_IN, | ||
} from '../../utils/constants'; | ||
|
||
export const DEFAULT_CONFIG_PER_VIEW_TYPE = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was moved from page-pages/index.js
to initialize the DEFAULT_VIEWS
with the layout data, which was not being initialized. It wasn't an issue until now because the table
doesn't have any layout
data, but the list
does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In terms of design I think we're in a good spot. There may be a11y details to refine, and we should fix the title truncation, but this can happen later.
Everything seems to be working well.
I'm merging this to continue work in the follow-ups. Please, do bring up any follow-up I've missed in post-merge reviews, so it's tracked and can be addressed. |
@@ -236,7 +236,8 @@ Array of operations that can be performed upon each record. Each action is an ob | |||
- `isLoading`: whether the data is loading. `false` by default. | |||
- `supportedLayouts`: array of layouts supported. By default, all are: `table`, `grid`, `list`. | |||
- `deferredRendering`: whether the items should be rendered asynchronously. Useful when there's a field that takes a lot of time (e.g.: previews). `false` by default. | |||
- `onSelectionChange`: callback that returns the selected items. So far, only the `list` view implements this. | |||
- `onSelectionChange`: callback that signals the user selected one of more items, and takes them as parameter. So far, only the `list` view implements it. | |||
- `onDetailsChange`: callback that signals the user triggered the details for one of more items, and takes them as paremeter. So far, only the `list` view implements it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's a world where this is the same as onSelectionChange
in other words, when a single item is selected in list view we navigate to "details" and vice versa
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's possible, indeed. The way it works now is optimized for being a listing: you navigate through the items, preview them, and can manage them. There's also the multi-selection use case for bulk editing that needs to be accommodated.
Follow-up that adds a "Add new page" button at #57685 |
Follow-up that adds a footer to the sidebar with the |
Part of #55083
Supersedes #57523 #57589
What?
Updates the root "Pages" section to go to pages dataviews. It also adds a "details" button to support the whole flow:
Gravacao.do.ecra.2024-01-09.as.09.34.31.mov
Why?
It's the target flow we want.
How?
Makes the
list
layout the default.Adds a "details" button to the list view item.
onDetailChange
callback to the DataViews API, so consumers can handle this action. Note that, at the moment, the details event redirects the user to the existing details page (see conversation). The immediate follow-up is to open this in the content frame, as per the mockup below.Updates the flows, so the back button works as follows: "Pages < DataViews < Details".
Testing Instructions
Test pages show the details:
Test the templates do not have the details button and works as before:
Follow-ups
Pages
#57685What'd be the best place? In the sidebar (like the current design) or in the content frame (like we do for templates)? Related conversation.Make it work like the block editor list view: use arrow keys to move up/down the list and right/left to move to/from details.