revite
revite copied to clipboard
bug: regression: pressing Esc while previewing an image does not dismiss it
What happened?
Previewing an image and subsequently pressing Esc should dismiss the preview as it has before.
Instead, nothing happens anymore.

Branch
Nightly (nightly.revolt.chat)
Commit hash
a190a51d0b597370e66de96f7c94592debb7705c
What browsers are you seeing the problem on?
Chrome, Microsoft Edge
Relevant log output
No response
Desktop
- [ ] Yes, this bug is specific to Revolt Desktop and is not an issue with Revolt Desktop itself.
PWA
- [ ] Yes, this bug is specific to the PWA.
Can also reproduce on Firefox using Nightly.
this is because the ImageViewer is now using the UI library https://github.com/revoltchat/revite/blob/a190a51d0b597370e66de96f7c94592debb7705c/src/context/intermediate/popovers/ImageViewer.tsx#L6
the old modal component had the following (which listened for "Escape" key clicks):
useEffect(() => {
if (props.disallowClosing) return;
function keyDown(e: KeyboardEvent) {
if (e.key === "Escape") {
onClose();
}
}
document.body.addEventListener("keydown", keyDown);
return () => document.body.removeEventListener("keydown", keyDown);
}, [props.disallowClosing, onClose]);
changed in https://github.com/revoltchat/revite/commit/41e533ab59ef2f32554632e417ffff6b1ad31cca
Fixed in 0d3f29515e3ec8f1aab179914aa6634d323b2ded, ImageViewer now uses ModalController which depends on ModalRenderer that has the following: https://github.com/revoltchat/revite/blob/f79288826849d0a6e64cb4e1e85b2830ccecc47b/src/controllers/modals/ModalRenderer.tsx#L13-L14
Closing due to rewrite, marking as potential issue in future by linking to https://github.com/revoltchat/frontend/issues/134.