When you click on the images on this page a modal opens with a larger preview of the image. It works fine.
I would like to be able to use the ESC key to close these modals. I have followed this guide:
But it is not working … any ideas?
When you click on the images on this page a modal opens with a larger preview of the image. It works fine.
I would like to be able to use the ESC key to close these modals. I have followed this guide:
But it is not working … any ideas?
Yeah, a native option for this would be great. Maybe they’ll consider adding it in.
Yes, but until then a custom JS (that works) would also be fine. @JvP did you manage to get the custom JS from this post to work?
Hi @JesperF,
The code in the reference thread works properly. On the other hand, I will check with our development team on this and will add this as a feature request for future consideration.
Thanks
Yes it still works here.
Thanks for adding a feature request for it
@tristup But I have used the code from this post and it is not working. Can you see what I’m doing wrong?
Did you add this as well?
Yes:
But thanks
The Frontend API has changed since that post. See the below for an updated version. We’re also just going to add this feature to our main codebase in Pro 6.4. Have a great weekend!
window.csGlobal.rivet.attach('[data-x-esc-close]', function(el) {
var id = el.getAttribute('data-x-toggleable')
window.addEventListener('keyup', function(e) {
if (e.key === 'Escape' && window.xToggleGetState(id)) {
window.xToggleUpdate(id, false)
}
}, { passive: true })
});
Fantastic, thanks and you have a great weekend too!
You are most welcome.
@charlie Thanks for the updated js code. I’ve added it as Global JS code on our site, but the ESC key is still not working
But it’s good to hear that a native ESC key solution will be added to the main codebase in Pro 6.4.
I guess I’ll just have to wait for this
Thanks again
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.