()
| 25 | // What a back press closes before history moves: the reading drawer, then |
| 26 | // the top-most sheet, menu or dialog. |
| 27 | export const closeTopLayer = (): boolean => { |
| 28 | if (requestReadingClose()) { |
| 29 | return true; |
| 30 | } |
| 31 | |
| 32 | if (!hasOpenLayer()) { |
| 33 | return false; |
| 34 | } |
| 35 | |
| 36 | (document.activeElement ?? document.body).dispatchEvent( |
| 37 | new KeyboardEvent('keydown', { |
| 38 | key: 'Escape', |
| 39 | bubbles: true, |
| 40 | cancelable: true, |
| 41 | }), |
| 42 | ); |
| 43 | return true; |
| 44 | }; |
| 45 | |
| 46 | // The web side of the wrappers' contract: what they call on the page |
| 47 | // (refresh, back), and what the page tells them (where it is, and a light |
no test coverage detected