-
Notifications
You must be signed in to change notification settings - Fork 43
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
Conversation
0e2e9c1
to
8256199
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
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
This comment was marked as outdated.
This comment was marked as outdated.
@@ -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}> |
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 expect this padding in CSS, but sadly I am not css expert. Lets hope @dgdavid gets back soon
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 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' }} |
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.
same here. I expect icon style to be in css
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.
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 |
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.
also here I expect some class and style defined in css.
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.
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.
@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 |
This comment was marked as outdated.
This comment was marked as outdated.
Co-authored-by: José Iván López <[email protected]>
@dgdavid oky then |
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
To make them accessible.
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.
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.
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 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.
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!
Which revealed that `pattern` property of `SoftwareConfig` type is actually optional.
Prepare for releasing Agama 10· * #1263 * #1330 * #1407 * #1408 * #1410 * #1411 * #1412 * #1416 * #1417 * #1419 * #1420 * #1421 * #1422 * #1423 * #1424 * #1425 * #1428 * #1429 * #1430 * #1431 * #1432 * #1433 * #1436 * #1437 * #1438 * #1439 * #1440 * #1441 * #1443 * #1444 * #1445 * #1449 * #1450 * #1451 * #1452 * #1453 * #1454 * #1455 * #1456 * #1457 * #1459 * #1460 * #1462 * #1464 * #1465 * #1466 * #1467 * #1468 * #1469 * #1470 * #1471 * #1472 * #1473 * #1475 * #1476 * #1477 * #1478 * #1479 * #1480 * #1481 * #1482 * #1483 * #1484 * #1485 * #1486 * #1487 * #1488 * #1489 * #1491 * #1492 * #1493 * #1494 * #1496 * #1497 * #1498 * #1499 * #1500 * #1501 * #1502 * #1503 * #1504 * #1505 * #1506 * #1507 * #1508 * #1510 * #1511 * #1512 * #1513 * #1514 * #1515 * #1516 * #1517 * #1518 * #1519 * #1520 * #1522 * #1523 * #1524 * #1525 * #1526 * #1527 * #1528 * #1529 * #1530 * #1531 * #1532 * #1533 * #1534 * #1535 * #1536 * #1537 * #1540 * #1541 * #1543 * #1544 * #1545 * #1546 * #1547 * #1548 * #1549 * #1550 * #1552 * #1553 * #1554 * #1555 * #1556 * #1557 * #1558 * #1559 * #1560 * #1562 * #1563 * #1565 * #1566 * #1567 * #1568 * #1569 * #1570 * #1571 * #1572 * #1573 * #1574 * #1575 * #1576 * #1577 * #1578 * #1579 * #1580 * #1581 * #1583 * #1584 * #1585 * #1586 * #1587 * #1588 * #1589 * #1590 * #1591 * #1592 * #1593 * #1596 * #1597 * #1598 * #1600 * #1602 * #1605 * #1606 * #1607 * #1608 * #1610 * #1611 * #1612 * #1613 * #1614 * #1619 * #1620 * #1621
For more details please read #1550 (review) (and maybe #1550 (review))