This PR is to allow for navigating between images using the left and right keyboard keys when viewed in the image dialog.
Build decisions:
Because the dialog does not have an input the event listener had to be added to document for the keys to fire the events.
Due to the listener being on document it is outside of the component scope so the state does not get updated on key pressed. According to this article there are a couple of ways around it. I chose event listener re-registration so that I did not need to keep 2 sets of state in sync (one foe keyboard, one for mouse) and existing functionality could be used.
Issue: https://github.com/usememos/memos/issues/4024
This PR is to allow for navigating between images using the
left
andright
keyboard keys when viewed in the image dialog.Build decisions:
document
for the keys to fire the events.document
it is outside of the component scope so the state does not get updated on key pressed. According to this article there are a couple of ways around it. I chose event listener re-registration so that I did not need to keep 2 sets of state in sync (one foe keyboard, one for mouse) and existing functionality could be used.