Skip to content

Fix #17563: NVUI - board becomes unresponsive after layout change#20074

Merged
ornicar merged 1 commit intolichess-org:masterfrom
Diogo1457:fix-17563
Mar 23, 2026
Merged

Fix #17563: NVUI - board becomes unresponsive after layout change#20074
ornicar merged 1 commit intolichess-org:masterfrom
Diogo1457:fix-17563

Conversation

@Diogo1457
Copy link
Contributor

Fix #17563: NVUI board becomes unresponsive after layout change

The board stopped responding to clicks and keyboard input after changing the layout in NVUI mode. This happened because event listeners were bound directly to button elements, which were destroyed and recreated during re-render, causing the listeners to be lost.

Fix

Replaced direct event binding with delegated events attached to the board container to ensure handlers persist across DOM updates.

Added namespaced event cleanup using $board.off('.nvui') to prevent duplicate bindings when the hook runs multiple times.

Updated the render hook to call boardEventsHook on both insert and update, ensuring events are consistently reattached after every re-render.

Testing

Manually tested by:

  • Playing a game in NVUI mode
  • Changing the board layout multiple times
  • Verifying that click and keyboard interactions continue to work correctly

Also ran all frontend tests and confirmed they pass.

Demo / Video

A short video demonstrating the bug and explaining the changes:

Watch the video

… change

The board stopped responding to clicks and keyboard input after
changing the layout in NVUI mode. This happened because event
listeners were bound directly to button elements, which were
destroyed and recreated during re-render, causing the listeners
to be lost.

Replaced direct event binding with delegated events attached to
the board container to ensure handlers persist across DOM updates.
Added namespaced event cleanup to prevent duplicate bindings.

Also updated the render hook to call boardEventsHook on both
insert and update, ensuring events are consistently reattached
after every re-render.
@yafred
Copy link
Contributor

yafred commented Mar 23, 2026

Thanks for the fix ... and, even better, for the PR style (so easy to review)

As for the nvui part, I confirm it solves the problem ...

There are 2 other boards that use the same model

@ornicar ornicar merged commit 8d08bb2 into lichess-org:master Mar 23, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nvui - changing board layout makes the board unusable

3 participants