question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tab order for confirm dialog buttons

See original GitHub issue

Current behaviour

When using the confirm component the secondary button has a higher tab order than the primary button. This means that when opening the component users automatically have the “No” option focused by default.

Screenshot 2021-02-16 at 11 44 42

Expected behaviour

As the primary action is the “Yes” option, it should come first in the tab order, so as to match the visual hierarchy of the page. This should not overwrite the users tab location as the dialog could have focusable content within it.

Reproducible example

https://carbon.sage.com/?path=/story/confirm--default-story

Suggested solution(s)

Swap the order of the buttons in the confirm component: https://github.com/Sage/carbon/blob/d1c72c1aecede2d228ed03aabd8a4f795c83dba1/src/components/confirm/confirm.component.js

Change the parent to use flex-direction: row-reverse.

https://github.com/Sage/carbon/blob/d1c72c1aecede2d228ed03aabd8a4f795c83dba1/src/components/confirm/confirm.style.js#L7

export const StyledConfirmButtons = styled.div`
  margin-top: 48px;
  display: flex;
  flex-direction: row-reverse;
  justify-content: flex-end;
`;

Additional context

In general the order of the markup should match how it is output onto the page. In this case, the right hand button is more prominent than the secondary button, so sighted users use this component like so:

image

This is also how we want users to interact with the element, so the markup makes semantic sense.

Your environment

Software Version(s)
carbon-react latest
carbon-factory
react-scripts
React
Browser
npm
Operating System

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
benwilsonsagecommented, Mar 11, 2021

Hi all - the Design System guidance on Forms says this right now…

Button Order: In a button pair, ‘Cancel’ goes on the left, and ‘Save’ goes on the right - a consensus of surveyed third party Design Systems does it this way (with Windows being a rare exception). Although Nielsen (2008) says “(neither) choice is likely to cause usability catastrophes”.

We’re due to discuss this in the Forms task force shortly, but the cost and inconsistency of changing approach is probably high.

The approach has the benefit that the dialog ‘ends’ with a positive conclusion, but the disadvantage that users must tab past the negative action to get to the positive.

I see the difficulty with that, but suggest that tab sequence following reading order (top-to-bottom, left-to-right) might be best.

1reaction
harpalsinghcommented, Feb 16, 2021

@MarkMizenSagecom I think there are few key things that come into play here:

  1. We used to make primary left/secondary right, but decision was made to switch that order (Ben might have a better idea why I think it was just general team preference)
  2. When a confirm or any dialog is fired, would we want the user to actively choose the “primary” option, as that will have a consequence, whereas the cancel does nothing, so accidentally pressing Enter doesn’t trigger the confirm primary action.
  3. From an accessibility POV if they meant to cancel, is it ok to expect Shift+Tab to go back or arrow key in this scenario?

Would be good to open up a chat with Martin Underhill too and discuss the options cause you make a valid question 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

tab order of help button in dialogs - UX Stack Exchange
What tab order should I use? It's obvious that the content panel uses tabindex values that correspond to the reading order which is...
Read more >
Set the tab order for controls - Microsoft Support
On the Design tab, in the Tools group, click Tab Order. In the Tab Order dialog box, under Section, click the section you...
Read more >
jquery dialog tabindex for buttons - Stack Overflow
Now it isn't possible to access the "Yes" Button with the TAB-key. Seams there is no TabIndex . How can I make this...
Read more >
Tab Order - Accessible Publishing Knowledge Base
The keyboard tab button provides a shortcut to move through interactive elements like hyperlinks, scripted controls, and forms. The sequence in which these ......
Read more >
Tab order dialog box| Simfatic Forms 5.0 Help
The tab order dialog box lists the input form elements in the form. You can change the sequence by moving the element up...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found