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

feature(web): make the product selection more appealing and accessible #1550

Merged
merged 22 commits into from
Sep 5, 2024

Conversation

lkocman
Copy link
Contributor

@lkocman lkocman commented Aug 21, 2024

  • Fixes Icons for individual distros #1415
  • Supply icon for all products and copy them to dist/assets/logos in final web build.
  • Add icon to structures, pass it to dbus, etc (please do not mix product icon with pattern icon) fallback to default.svg in case that no icon is set
Before After
Screenshot of the previous product selection page Screenshot of the new product selection page

For more details please read #1550 (review) (and maybe #1550 (review))

@lkocman lkocman force-pushed the icons branch 2 times, most recently from 0e2e9c1 to 8256199 Compare August 21, 2024 19:04
@lkocman

This comment was marked as outdated.

@coveralls

This comment was marked as outdated.

* Resolves Issue agama-project#1415

* Entire card is clickable, selection of card
  is still marked by blue boarder

* Add icon to structures, pass it to dbus, etc
  (please do not mix product icon with pattern icon)
  fallback to default.svg in case that no icon is set

* Rework button layout to clickable layout

* We might need to use table or similar in case that
  description is longer than the

* Supply icon for all products including default icon
@lkocman

This comment was marked as outdated.

@lkocman lkocman added enhancement New feature or request help wanted Extra attention is needed ux UX related bugs/improvements labels Aug 21, 2024
@@ -46,34 +47,57 @@ function ProductSelectionPage() {
}
};

const Item = ({ children }) => {
const Item = ({ children }) => (
<GridItem sm={10} smOffset={1} lg={8} lgOffset={2} xl={6} xlOffset={3}>
Copy link
Contributor

Choose a reason for hiding this comment

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

I expect this padding in CSS, but sadly I am not css expert. Lets hope @dgdavid gets back soon

Copy link
Contributor

Choose a reason for hiding this comment

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

This is not a change from @lkocman. In any case, it is just using available props of a PatternFly component. They are later translated in style changes. I tend to avoid using layout props as much as possible, but these ones are for a responsive layout. Let's see if we manage to find a better way in the future, but for now it's the way to go in this special cases.

src={productIcon}
alt={alt}
width="80px"
style={{ height: 'auto', width: '10%', float: 'left', padding: '0 20px 20px 0' }}
Copy link
Contributor

Choose a reason for hiding this comment

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

same here. I expect icon style to be in css

Copy link
Contributor

Choose a reason for hiding this comment

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

same here. I expect icon style to be in css

Exactly, styles should live in a CSS file instead of be hardcoded in the component. Would be nice to make something generic in order to Be the browser’s mentor, not its micromanager. At this moment Agama CSS files are a bit messy, since we still a few more cleanup rounds to get them in a better shape.

I can help @lkocman with this since I fully understand it is a bit painful to deal with this topic due to the situation. In the future, almost all of this things should be themeable.

onClick={() => handleCardClick(product)}
style={{
cursor: 'pointer', // Change the cursor to indicate clickable
border: nextProduct === product ? '2px solid #51c38d' : 'none', // highlight selected card
Copy link
Contributor

Choose a reason for hiding this comment

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

also here I expect some class and style defined in css.

Copy link
Contributor

@dgdavid dgdavid Aug 29, 2024

Choose a reason for hiding this comment

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

also here I expect some class and style defined in css.

Sure, let's extract these things to CSS rules but carefully for not ending having thousand of rules for every thing. I'll come up with some proposals on top of this once I find a bit of time to address it.

But have in mind two things,

  • Here @lkocman is forcing a cursor because using the onClick prop for the card after dropping the radio button. It's not wrong, but I'd prefer to somehow revert the behavior for laying out the card content with the radio and its label if possible. The benefit it that the browser will be able to hint the users without the need of changing the styles. Will be clear with an example (to be created)
  • The fact that border is styled as none when the current product is selected plus the "Change" button disabled and a tiny bug I found in master branch with the focus lost because a re-draw makes me think that currently selected product shouldn't be part of the options to select. Our fault, but something to think about and, most probably, to improve.

@jreidinger
Copy link
Contributor

@dgdavid after consulting with patternfly documentation, I would say that for product selection we maybe can use Tile component, what do you think? https://www.patternfly.org/components/tile#with-long-subtext

@lkocman

This comment was marked as outdated.

@lkocman
Copy link
Contributor Author

lkocman commented Sep 4, 2024

@dgdavid oky then

dgdavid added a commit to lkocman/agama that referenced this pull request Sep 4, 2024
Since it's arguably that they might confuse users and also because of
consistent with the rest of the UI. They could be drop or hidden later,
but thinking globally in all selectors and implications of doing so.

Also, this commit improves a little the proposed layout by making use of
the label for "increasing" the clickable area instead of adding a
handler for the PF/Card component itself. Again, this can be refactored
later if really needed.

Read the reasoning at
agama-project#1550 (review)
and/or agama-project#1550 (comment).
Since it's arguably that they might confuse users and also because of
consistent with the rest of the UI. They could be drop or hidden later,
but thinking globally in all selectors and implications of doing so.

Also, this commit improves a little the proposed layout by making use of
the label for "increasing" the clickable area instead of adding a
handler for the PF/Card component itself. Again, this can be refactored
later if really needed.

Read the reasoning at
agama-project#1550 (review)
and/or agama-project#1550 (comment).
As a result of an internal component defined in the body of the main
component (aka "render function"), the focus was lost each time the main
component got re-rendered because of a "selected product" changed.

This happens because these internal components are actually not
re-rendered but remounting since they were re-defined :/ A bit messy,
but there is a lot of documentation about it. To link a few,

  * https://react.dev/learn/preserving-and-resetting-state#different-components-at-the-same-position-reset-state
    - Which contains a "Pitfall" warning that says: **This is why you
      should not nest component function definitions.**
  * https://www.developerway.com/posts/react-re-renders-guide#part3.1
@dgdavid
Copy link
Contributor

dgdavid commented Sep 4, 2024

BTW, manually testing your changes I've found an a11y bug on the master branch: the focus is lost because the entire selector is redrawn every time the selection changes. A bit technical, but this happens because it is a controlled form in order of being able to know if the selection matches the already selected product. This, along with a condition you used for adding a border or not depending on the same condition, made me think that it does not make sense to have the selected product as part of the selector. Of course, it should be on the selection page, but not as an option, although this is for another PR 😉

As said, not related to this PR but I took the opportunity and fixed it as part of it :) See 3cb7ebf

It wasn't a (direct) consequence of being a controlled form but because a nested component definition. Anyway, users can now select the product using the keyboard too, but still thinking that selected product should not be part of the offered options. A better layout is needed to inform the user not only about the currently selected product but also about the consequences of changing it... but, now for real, in another PR 😃

For improving its a11y when using an screen reader.

Also makes the PF/Card element clickable as proposed by @lkocman
initially ease the selection for mouse users, but keeping the radio
inputs as both, visual and keyboard aid.
@dgdavid
Copy link
Contributor

dgdavid commented Sep 5, 2024

@dgdavid after consulting with patternfly documentation, I would say that for product selection we maybe can use Tile component, what do you think? https://www.patternfly.org/components/tile#with-long-subtext

Sorry @jreidinger, I had overlooked this comment.

No please, do not use PF/Tile. It will be deprecated in favor of PF/Card, see patternfly/patternfly-react#8542. I mentioned it a couple of months ago when working in storage part, see 8d432fb, which is also no longer avialable.

The idea, as commented in team meetings, is to keep component as simple as possible, closer to HTML the better. At least by now, since there a lot of things to do in a limited period of time :) In any case, the whole UI will be benefit from using simple, yet understandable elements or components.

Thanks a lot for having a look anyway. You rocks!

Kind of undoing some changes made at
ec57cc1 related to the clickable card.
It made a11y tools complain about "Clickable elements must be focusable
and should have interactive semantics" which makes sense.

Instead of start adding keyboard handlers to the PF/Card component too
this commit uses a CSS technique for "expanding" the area of the label
to the whole card and using the pointer cursor, while keeping the
details out of the label but the cursor: pointer. That way, the
component still accessible for keyboard and screen reader while improve
the mouse users experience too.
@dgdavid dgdavid changed the title Decorated product selection without radio btn feature(web): make the product selection more appealing and accessible Sep 5, 2024
Copy link
Contributor

@dgdavid dgdavid left a comment

Choose a reason for hiding this comment

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

@lkocman, @jreidinger,

Here I go 🙄

I've reworked the proposed changes for having these logos in the UI but keeping it as much accessible as possible with our (yet limited) knowledge to that regard.

But before entering in details, let me thanks @lkocman again for the contribution since it has been not only an step forward for having the product logos in the selection page, but hopefully a turning point regarding to a11y in Agama.

As you can see in the changes, I've removed the onClick prop from the PF/Card. If you go commit by commit, you'll see that I restored it at some point, but a11y Firefox tool complained about https://developer.mozilla.org/en-US/docs/Web/Accessibility/Understanding_WCAG/Keyboard#clickable_elements_must_be_focusable_and_should_have_interactive_semantics.

Firefox a11y tools complaining

Thus, I've used a CSS technique for expanding the area of the label to the whole card in addition to force the pointer cursor for it in this case (by default, labels are clickable but use the default cursor). That way, what @lkocman was looking for is achievable without defeating the keyboard usability (I believe).

You may wonder why I didn't use the PF/Card with selectable and clickable properties. I simply did not have as much PF knowledge as I'd like and also find selectable&clickable card rather complex at this moment.

I also tried to follow and accomplish the PF/Card a11y testing check list, https://www.patternfly.org/components/card/accessibility#testing

Since product descriptions are usually long, I have marked them as aria-details in order to prevent the screen reader reading the whole text before announcing the "not selected radio button" or "selected radio button" state, which would be a bit annoying IMHO. What is more, from my POV these descriptions perfectly fits as details.

Last but not least, you will see that I have added the "Select a product" label (actually a legend) there. I know it's tempting to remove it, but users need a context. Not you, not me, not even most of the guys we know... but there are users that need such a context. I'm saying that because it's true that an aria attribute will be enough for screen reader users, but I really believe that such a selector needs a bit of context when a user lands there. In other words, IMHO it is not superfluous but contributes.

You can check the visual result by yourself. And play the below videos to see how keyboard and screen reader are supported.

  • Using the selector with mouse and keyboard

    product-selection-keyboard-support.mp4
  • Using an screen reader and keyboard (you might need to unmute the video)

    product-selection-screenreader-support.mp4

Please, look at this as just an step forward. Any other change or improvement like

A better layout is needed to inform the user not only about the currently selected product but also about the consequences of changing it

can be properly addressed in a next iteration in order to not end up with an endless PR.

Thanks a lot!

service/lib/agama/software/product.rb Outdated Show resolved Hide resolved
service/package/rubygem-agama-yast.changes Outdated Show resolved Hide resolved
web/src/components/core/ChangeProductLink.test.tsx Outdated Show resolved Hide resolved
@imobachgs imobachgs merged commit fde927e into agama-project:master Sep 5, 2024
5 checks passed
@imobachgs imobachgs mentioned this pull request Sep 20, 2024
imobachgs added a commit that referenced this pull request Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed ux UX related bugs/improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Icons for individual distros
6 participants