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.

Focus on wrong button in modal

See original GitHub issue

The cancel button is focused in modal instead of primary button

What package(s) are you using?

  • carbon-components
  • [X ] carbon-components-react

Detailed description

When a modal component is opened the close button (X) is focused instead of the primary button.

Is this issue related to a specific component?

This is related to the Modal component

What did you expect to happen? What happened instead? What would you like to see changed?

Focus should be on the primary button.

What browser are you working in?

Chrome

What version of the Carbon Design System are you using?

Carbon X

Steps to reproduce the issue

This can also be seen in the story book: https://react.carbondesignsystem.com/?path=/story/modal--default

Additional information

There are two references to this.button in the code (Module.js). That seems to cause the error. One is https://github.com/carbon-design-system/carbon/blob/v10.10.0/packages/react/src/components/Modal/Modal.js#L346, another is https://github.com/carbon-design-system/carbon/blob/v10.10.0/packages/react/src/components/Modal/Modal.js#L411. The code seems to have been originated from carbon-design-system/carbon-components-react#980.

image

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
renmaddoxcommented, Mar 24, 2020

While I would prefer better support for this in Modal, you should be able to set the selectorPrimaryFocus to ['.bx-btn-primary','.bx-btn-danger'].

0reactions
emyarodcommented, Mar 24, 2020

@miriam-g as @renmaddox mentions you can set selectorPrimaryFocus to the CSS selector of the element you want to focus

Read more comments on GitHub >

github_iconTop Results From Across the Web

Disable auto focus in dialog- modal in Angular 2/ material
The problem is: I can't disable auto focus when modal-dialog is opened in iPhone or tablet especially. In iOS, it automatically focuses the ......
Read more >
How to set focus on input in modal? - MDBootstrap
If I use <input autofocus> or attempt to set focus dynamically on an input inside modal body, it would not work. How do...
Read more >
Modal with auto-focus
Modal with an auto-focused button. auto-focus is generally not recommended from an accessibility point of view, but maybe useful for some times of ......
Read more >
Modal - Bootstrap
Use Bootstrap's JavaScript modal plugin to add dialogs to your site for lightboxes, user notifications, or completely custom content.
Read more >
Focus management and inert | CSS-Tricks
One instance of this is bad enough. ... After the modal is closed focus is returned to the button that triggered the modal....
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