diff --git a/.changeset/scope-keys.md b/.changeset/scope-keys.md index f095533..859b89f 100644 --- a/.changeset/scope-keys.md +++ b/.changeset/scope-keys.md @@ -8,10 +8,10 @@ The lightbox's keys now act only while focus is inside it, so text fields, selec - Now the lightbox handles keys in an `onKeyDown` on its dialog, or on the carousel's root with `inline`. Keys pressed elsewhere on the page don't reach it. - While the modal lightbox is open, it also takes keys pressed while nothing has focus, as if they were pressed in it. Focus falls to `
` when the focused control turns disabled or leaves the page, as a Next button rendered with `disabled={!canNext}` does on the last image. Such a key also moves focus back into the lightbox. Tab then goes to its first control and Shift+Tab to its last. - ← and → leave text fields, selects, and other editable elements alone. Escape still closes the lightbox from a text field, unless the field calls `preventDefault()` in its own `onKeyDown`. -- ←, →, and Escape do nothing with Alt, Ctrl, or Cmd held, so browser and system shortcuts such as Alt+← keep working. Keys pressed while an input method composes text do nothing at all. +- ←, →, and Escape do nothing with Alt, Ctrl, or Cmd held, so browser and system shortcuts such as Alt+← keep working. Keys pressed while an input method composes text do nothing at all. That includes the Escape that cancels a composition in Safari, which fires `compositionend` first and marks that `keydown` only with `keyCode` 229. With 1.9.0, the lightbox didn't check for composition, so the Escape that cancels a Chinese or Japanese composition could close it. - The keys act when they go down instead of when they come up. Holding an arrow key still pages once. - While the modal lightbox is open, ↑, ↓, PageUp, PageDown, Home, and End pressed in it don't scroll the page behind it, with or without Alt, Ctrl, or Cmd, unless a text field has focus. Space doesn't scroll it either, unless Space presses a focused button. With 1.9.0, Space scrolled the page behind the lightbox. Keys pressed in content portaled out of the lightbox, such as a menu that a header button renders into ``, are left to that content, so they scroll the page behind unless that content prevents them. An `inline` carousel never blocks these keys. -- Tested with the unit tests on React 19 and React 18.3.1, the Playwright tests in Chromium, Firefox, and mobile Chromium on React 19, and the Chromium Playwright tests on React 18.3.1. CI runs the WebKit projects. +- Tested with the unit tests on React 19 and React 18.3.1, the Playwright tests in Chromium, Firefox, and mobile Chromium on React 19, and the Chromium Playwright tests on React 18.3.1. CI runs the WebKit projects. A unit test covers the Safari input-method case with the `keydown` that Safari sends. It was not tested in Safari with an input method. Upgrade notes: diff --git a/src/__tests__/opening-and-closing.test.tsx b/src/__tests__/opening-and-closing.test.tsx index 61ab63b..407e393 100644 --- a/src/__tests__/opening-and-closing.test.tsx +++ b/src/__tests__/opening-and-closing.test.tsx @@ -180,6 +180,16 @@ describe('closing', () => { expect(props.onClose).not.toHaveBeenCalled(); }); + test('Esc that ends input method composition in Safari leaves it open', () => { + const props = lightboxProps({ renderFooter: () => }); + render(