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

Modal: selectorPrimaryFocus doesn't work, when used together with focusTrap #4088

Closed
1 of 2 tasks
elbrus opened this issue Sep 25, 2019 · 1 comment · Fixed by #4172
Closed
1 of 2 tasks

Modal: selectorPrimaryFocus doesn't work, when used together with focusTrap #4088

elbrus opened this issue Sep 25, 2019 · 1 comment · Fixed by #4172

Comments

@elbrus
Copy link

elbrus commented Sep 25, 2019

What package(s) are you using?

  • carbon-components
  • carbon-components-react

Detailed description

Describe in detail the issue you're having.

I want to focus specific element by using provided selectorPrimaryFocus. But it doesn't work if I use focusTrap as well.

Is this issue related to a specific component?

Modal

What did you expect to happen?

custom element should be focused

What happened instead?

close button was focused

What would you like to see changed?

focusTrapOptions={{ initialFocus: this.initialFocus }}>

initialFocus from focus trap library doesn't have any arguments, which makes this.initialFocus to skip handling selectorPrimaryFocus (line#223)

What browser are you working in?

any browser

What version of the Carbon Design System are you using?

latest

Steps to reproduce the issue

  1. https://codesandbox.io/s/codesandbox-lwl17
  2. input will be focused (might need to refresh inside code sandbox to see input inside modal focused)
  3. change focusTrap to be true and refresh
  4. close button will be focused

Additional information

not related, but you have different refs assigned to the same variable:

  • line#313 ref={this.button}
  • line#362 inputref={this.button}
@asudoh
Copy link
Contributor

asudoh commented Sep 26, 2019

Hi 👋 thank you for reporting - And good findings. Contributions welcome!

joshblack pushed a commit that referenced this issue Oct 8, 2019
* fix(modal): find primary focus element for selectorPrimaryFocus

Closes #4088

* fix(modal): assign innerModal ref to focusContainerElement if undefined

Supports PR #4172

* chore(modal): remove focusTrap from Modal story

By default, focusTrap is true.

Supports PR #4172

* chore(modal): add containerElement guard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants