Files
editor/CHANGELOG.md
T
CHIIMYEN 95bf5f2c55 Fix keyboard shortcuts being ignored while the map has focus (#2157)
## Launch Checklist

 - [x] Briefly describe the changes in this PR.
 - [x] Link to related issues.
- [ ] Include before/after visuals or gifs if this PR includes visual
changes. — not applicable, nothing visual changes.
 - [x] Write tests for all new functionality.
 - [x] Add an entry to `CHANGELOG.md` under the `## main` section.

### What changed

Keyboard shortcuts went dead as soon as the map had focus.

The global `keyup` handler in `App.tsx` gated shortcuts on
`document.activeElement === document.body`. That reads like "the user is
not
typing", but it actually asks "is nothing focused at all". Clicking the
map makes
`.maplibregl-canvas` the active element, so every shortcut stopped
working until the
map was blurred.

The `m` shortcut demonstrates the problem nicely: its entire job is to
focus that
canvas, so pressing `m` silently disabled all shortcuts until `Esc`.
That path is
covered by an existing test (`'m' should focus map`), which is why the
regression
was easy to miss.

### How

`isTextEntryElement()` now answers the question the guard was reaching
for, so
shortcuts are suppressed only for text entry targets:

`input`, `textarea`, `select`, and `contenteditable` — the last one
covering the
CodeMirror editor, which is a `contenteditable` `.cm-content`.

The check stays independent of either renderer's DOM. MapLibre's
`.maplibregl-canvas` and the OpenLayers viewport live in different
structures, so an
allow-list of canvas class names would have fixed one renderer and left
the other
broken.

### Behaviour change

Single-letter shortcuts now also fire while focus is on a button or a
panel, where
previously they did not. That is inherent to making the map case work —
the old
predicate simply excluded everything that was not `document.body`. Per
@HarelM, this
can be reverted if anyone complains.

### Tests

`e2e/keyboard.spec.ts` gains a `while the map has focus` block. Its
`beforeEach`
focuses the canvas through the `m` shortcut and asserts the canvas
really is focused,
then two independent tests check that `!` and `s` still open their
modals.

Verified the new tests fail without the fix:

```
Error: expect(locator).toBeVisible() failed
Locator: locator('[data-wd-key="modal:debug"]').first()
Expected: visible
Error: element(s) not found
```

and pass with it.

Local results:

| Check | Result |
|---|---|
| `npm run lint` | clean |
| `npx vitest run` | 9 files, 50 tests passed |
| `npx vite build --mode=production` | clean |
| `npx playwright test` | 170 passed, 3 failed |

The 3 failures — `modals › open › upload via drag and drop`,
`modals › global state › remove variable` and `modals › global state ›
edit variable key`
— also fail on unmodified `main`, so they are pre-existing and unrelated
to this
change.

Fixes #940
2026-09-14 08:33:39 +03:00

4.4 KiB

main

Features and improvements

  • Replace Cypress with Playwright for end-to-end tests and Vitest browser mode (Playwright provider) for component tests; drop the @shellygo/cypress-test-utils helper in favour of a MaputnikDriver page object
  • Upgrade to MapLibre GL JS 6 and Vite 8, and update the remaining dependencies
  • Serve the RTL text plugin from @mapbox/mapbox-gl-rtl-text instead of a pinned CDN URL, so its version is tracked in package.json
  • Exported HTML now loads MapLibre GL JS as an ES module, since v6 no longer ships a UMD bundle
  • ...Add new stuff here...

🐞 Bug fixes

  • Prevent a crash when converting a function to an expression
  • Prevent a crash when deleting either stop from a function with two stops
  • Preserve expanded layer groups when deleting layers, including the first layer of a group
  • The map's data listener now fires on tile loads again, so source and vector layer field autocompletion is populated
  • The maputnik desktop binary now opens the default browser automatically on startup (opt out with --no-browser)
  • Keyboard shortcuts now keep working while the map has focus, instead of going dead until the map is blurred
  • ...Add new stuff here...

3.1.0

Features and improvements

  • Added translation to "Links" in debug modal
  • Add support for hillshade's color arrays and relief-color elevation expression
  • Change layers icons to make them a bit more distinct
  • Remove @mdi packages in favor of react-icons
  • Add ability to control the projection of the map - either globe or mercator
  • Add markdown support for doc related to the style-spec fields
  • Added global state modal to allow editing the global state
  • Added color highlight for problematic properties
  • Upgraded codemirror from version 5 to version 6
  • Add code editor to allow editing the entire style
  • Add support for sprite object in setting modal
  • Set the correct map view when opening a new style on an empty map
  • Allow root-relative urls in the stylefile

🐞 Bug fixes

  • Improved the local style open modal and local file upload.
  • Fixed the Expression editor (for long expressions) being able to be float under other components further down
  • Fixed an issue when clicking on a popup and then clicking on the map again
  • Fix modal close button position
  • Fixed an issue with the generation of translations
  • Fix missing spec info when clicking next to a property
  • Fix Firefox open file that stopped working due to react upgrade
  • Fix issue with missing bottom error panel
  • Fixed headers in left panes (Layers list and Layer editor) to remain visible when scrolling
  • Fix error when using a source from localhost
  • Fix an issue with scrolling when using the code editor

3.0.0

Features and improvements

  • Fix radio/delete filter buttons styling regression
  • Add german translation
  • Use same version number for web and desktop versions
  • Add scheme type options for vector/raster tile
  • Add tileSize field for raster and raster-dem tile sources
  • Update Protomaps Light gallery style to v4
  • Add support to edit local files on the file system if supported by the browser
  • Upgrade to MapLibre LG JS v5
  • Upgrade Vite 6 and Cypress 14 (#970)
  • Upgrade OpenLayers from v6 to v10
  • When loading a style into localStorage that causes a QuotaExceededError, purge localStorage and retry
  • Remove react-autobind dependency
  • Remove usage of legacy childContextTypes API
  • Refactor Field components to use arrow function syntax
  • Replace react-autocomplete with Downshift in the autocomplete component
  • Add LocationIQ as supported map provider with access token field and gallery style
  • Use maputnik go binary for the docker image to allow file watching
  • Revmove support for debug and localport url parameters
  • Replace react-sortable-hoc with dnd-kit to avoid react console warnings and also use a maintained library

🐞 Bug fixes

  • Fix incorrect handing of network error response (#944)
  • Show an error when adding a layer with a duplicate ID
  • Replace deprecated ReactDOM.render usage with createRoot and drop the DOMNodeRemoved cleanup hack

2.1.1

Features and improvements

  • Add GitHub workflows for releasing new versions
  • Update desktop build to pull from this repo (#922)

2.0.0

  • Update MapLibre to version 4 (#872)
  • Start continuous deployment of maputnik website

1.7.0