hledger icon indicating copy to clipboard operation
hledger copied to clipboard

hledger-web add form: key sequence a, ESC, a does not work in safari

Open simonmichael opened this issue 3 years ago • 0 comments
trafficstars

On mac, in Brave or Firefox, a opens the (modal dialog version of the) add form, ESC closes it, and a opens it again. But in Safari, the second a has no effect; you must first click on the page to reset the focus.

I tried to fix, but these waters run deep; please help if you can.

Some notes:

The a key is bound to the body element here: https://github.com/simonmichael/hledger/blob/c97e05e0d/hledger-web/static/hledger.js#L43

Show/hide actions for the modal dialog are defined here: https://github.com/simonmichael/hledger/blob/c97e05e0d/hledger-web/static/hledger.js#L20:L28 https://github.com/simonmichael/hledger/blob/c97e05e0d/hledger-web/static/hledger.js#L170:L174 https://github.com/simonmichael/hledger/blob/c97e05e0d/hledger-web/static/hledger.js#L180:L185

A workaround sometimes used for sequencing issues: https://stackoverflow.com/questions/7046798/jquery-focus-fails-on-firefox/7046837#7046837

Detecting the currently focussed element: https://developer.mozilla.org/en-US/docs/Web/API/Document/activeElement https://developer.mozilla.org/en-US/docs/Web/API/Document/hasFocus

Some history of focus in Safari: https://itnext.io/fixing-focus-for-safari-b5916fef1064

hledger-web can be run in GHCI for quicker testing with: make ghci-web After making changes in hledger.js: touch StaticFiles.hs, :reload in GHCI, and shift-reload the page in Safari.

simonmichael avatar Aug 29 '22 09:08 simonmichael