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

key listeners inside a modal don't fire anymore #2066

Closed
stianjensen opened this issue Jan 5, 2021 · 5 comments · Fixed by #2073
Closed

key listeners inside a modal don't fire anymore #2066

stianjensen opened this issue Jan 5, 2021 · 5 comments · Fixed by #2073

Comments

@stianjensen
Copy link

  • components: Modal
  • reactstrap version #8.8.0
  • import method es
  • react version #17.0.0
  • bootstrap version #4.5.3

What is happening?

Inside a Modal component, i am using react-image-lightbox for a small image gallery. When the image lightbox is visible I press my keyboard arrow keys, and the current image is not changing.

What should be happening?

Keybinds should work to navigate through images like they did when using reactstrap 8.7.1.

Steps to reproduce issue

  1. Install both reactstrap and react-image-lightbox (I'm sure other packages and use-cases are affected as well, but this is how I discovered the issue)
  2. Embed a Lightbox component within a Modal.
  3. Try using keyboard shortcuts set up by the lightbox component.

Error message in console

No error output

Code

Reproduce:
https://stackblitz.com/edit/reactstrap-7upqrn?file=Example.js

Changing the reactstrap version from 8.8.1 to 8.7.1 in package.json makes the navigation work again.

I've installed builds of reactstrap locally and pinned down the issue to stem from the following commit:
bf46484

@kyletsang
Copy link
Member

Looks like the focus is stuck on the "open gallery" button, so all key events aren't targeting the lightbox.

@kyletsang kyletsang added the bug label Jan 5, 2021
@kyletsang
Copy link
Member

Also, lightbox is opening it's own portal, so any focus capturing assumption we have in modal won't really work.

@kyletsang
Copy link
Member

@stianjensen can you do something like this? https://stackblitz.com/edit/reactstrap-omwcih?file=Example.js

This sandbox modifies yours by adding a new portal target for rendering the lightbox, so instead of rendering at the body level, it renders within the modal.

@stianjensen
Copy link
Author

Yeah, that looks like it works well - thanks!

@kyletsang kyletsang removed the bug label Jan 5, 2021
@kyletsang
Copy link
Member

Cool thanks for confirming. Not sure if there's anything we can change on our end for that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants