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

Theme previewer: Use listbox for theme patterns & style variation lists to improve selection UX #126

Merged
merged 13 commits into from
Jun 17, 2024

Conversation

ryelle
Copy link
Collaborator

@ryelle ryelle commented Jun 17, 2024

This updates the "Theme patterns" and "Theme style variations (items)" blocks to use the listbox UI pattern for interaction. In this pattern, the current item has a "selected" role, and is visually (and semantically) flagged. The current selected item can also be (optionally) unselected. This also introduces new styles for hover, focus, and selected states.

The change also applies to the Patterns list on single theme pages, where selecting an item triggers the navigation to open the pattern in the previewer (which is the current behavior). Some of the style changes (hover state) also apply to style variations on the single theme page, but I didn't change the interaction pattern here.

Fixes #113.

Tech details: This introduces a new helper script, wporgListbox, a JS class which sets up the listbox behavior for the two blocks. It sets up the interaction listeners (focus, keydown, click), and triggers a custom event for selection that other blocks can listen for. The new listbox elements (uls) are a single tabstop in the page, and to navigate through the items you use a keyboard (much nicer on themes with many patterns).

Note that I did not use the Interactivity API for this— I ran into an initial roadblock, and decided the wporgListbox class would be more understandable.

Screenshots

Screenshot 2024-06-17 at 11 53 05 AM
ScreenFlow.mp4

How to test the changes in this Pull Request:

  1. View a theme with style variations and/or patterns in the previewer
  2. Click on the style variations/patterns
  3. You should see the hover style (zoom), and the focus+selected states after selecting one
  4. It should update the previewer
  5. Click away and the selected state should stay
  6. Try using a keyboard, note that once an item has focus, use the arrow keys to change focus
  7. You should be able to follow your keyboard focus visually
  8. Use space or enter to select an item
  9. It should update the previewer
  10. Try unselecting a selected pattern
  11. It should send the previewer back to the theme homepage

Optionally try this with a screenreader or mobile device.

@ryelle ryelle self-assigned this Jun 17, 2024
@ryelle ryelle merged commit 2ba90fc into trunk Jun 17, 2024
@ryelle ryelle deleted the update/preview-pattern-selection branch June 17, 2024 16:00
@ryelle
Copy link
Collaborator Author

ryelle commented Jun 17, 2024

I've deployed this so that it can be tested on the live preview site— but I would still appreciate any feedback on the code or design. You can follow the test instructions above. cc @ndiego @StevenDufresne @adamwoodnz @WordPress/meta-design

Comment on lines +11 to +12
this.selected = state.initialSelected > 0 ? state.initialSelected : null;
this.current = null;
Copy link

@adamwoodnz adamwoodnz Jun 18, 2024

Choose a reason for hiding this comment

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

It's not immediately clear to me what the difference is between these two; I'm gaining an understanding as I read through, but I think some doc comments would help.

@adamwoodnz
Copy link

For keyboard navigation it's definitely a little jarring moving between style variations and patterns on the single theme page (tab stops), so would be good to update the variations to match.

border-color: var(--wp--preset--color--light-grey-1);
}

.wp-block-wporg-screenshot-preview:not(.is-preview-image):hover img {
Copy link

@adamwoodnz adamwoodnz Jun 18, 2024

Choose a reason for hiding this comment

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

I find it a bit strange when hovering not to get a pointer style cursor, for elements I can interact with.

Goes for both variations and patterns.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, the cursor was raised in #128, so that'll be fixed.

@adamwoodnz
Copy link

  • Try unselecting a selected pattern
  • It should send the previewer back to the theme homepage

Should the theme homepage option then be selected? For me the previewer changes and the item I deselected loses selected state, but the homepage does not become selected.

@adamwoodnz
Copy link

Works well for me with keyboard and mouse, however when I have VoiceOver activated I can't select style variations or patterns using my keyboard. I can tab to the lists and they are announced, and I can then navigate within the lists, but enter or space both fail to load the selected item. In this video I am hitting enter or space on each item after it is focused:

Kapture.2024-06-18.at.13.06.54.mp4

@ryelle
Copy link
Collaborator Author

ryelle commented Jun 18, 2024

For keyboard navigation it's definitely a little jarring moving between style variations and patterns on the single theme page (tab stops), so would be good to update the variations to match.

Yeah, I think that would be a good post-launch task.

Should the theme homepage option then be selected? For me the previewer changes and the item I deselected loses selected state, but the homepage does not become selected.

I'm not sure what you mean by this, there is no "homepage option" for patterns. If you're on the theme homepage, you're not viewing a pattern (some themes do have patterns that reflect parts of the homepage, but those are not the same).

Works well for me with keyboard and mouse, however when I have VoiceOver activated I can't select style variations or patterns using my keyboard.

Strange, it was working for me yesterday, I'll try again.

@ryelle
Copy link
Collaborator Author

ryelle commented Jun 18, 2024

I think the voiceover issue is not actually an issue— I can trigger the selection by hitting VO+Space which is the way most VO users would use it. Space by itself doesn't work, but I think that's a VO compat issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Theme preview: After selecting a pattern, there is no way to go back to the main theme
2 participants