Skip to content

fix(block): notify changes from native select elements - #3025

Merged
neSpecc merged 2 commits into
codex-team:nextfrom
Sawtone:fix/select-onchange-2975
Sep 17, 2026
Merged

neSpecc merged 2 commits into
codex-team:nextfrom
Sawtone:fix/select-onchange-2975

Conversation

@Sawtone

@Sawtone Sawtone commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Fixes #2975.

Native <select> value changes do not produce DOM mutations, so selecting an option can update a Tool's saved data without triggering onChange. This PR routes native select changes through the existing Block update pipeline.

The listener is delegated to the Block holder, supporting multiple selects and replacement Tool roots. It runs during bubbling so the Tool's own change handler updates its state before updated() runs. Registration is synchronous and removal happens in Block.destroy(), preventing deferred initialization from reinstalling this listener after destruction.

Validation

  • onchange.cy.ts: 30/30 passed with Cypress 13.13.3 and Electron 118 against a temporary Vite source fixture with a module-load wait.
  • Chromium checks confirmed correct Tool callback ordering and select listener cleanup, including destruction before deferred initialization.
  • ESLint on all four changed files: 0 errors, 6 existing warnings.
  • git diff --check passed.

The temporary test runner and source fixture changes are not included in this PR. The production build and full cross-browser suite were not run locally.

Credits

The SelectTool fixture and initial regression tests are adapted from Sion612/editor.js#1. Thanks @Sion612 for that work.

Additional coverage checks composite Tools, Tool callback ordering, and destruction before deferred initialization.

Delegate select change events to the Block holder during bubbling, keeping
Tool state updates ahead of the updated hook. Register synchronously and
remove the listener on destruction to avoid deferred rebinding.

Adapt the SelectTool fixture and initial regression tests from Sion612's
fork-local PR, and cover composite Tools, callback ordering, and early
destruction.

Tests adapted from: Sion612#1
Fixes codex-team#2975

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No unresolved review issues were identified.

Pull request overview

Fixes native <select> change detection so Tool updates trigger the existing Block pipeline and onChange callbacks.

Changes:

  • Adds delegated select-change handling and lifecycle cleanup.
  • Adds regression coverage for ordering, replacement roots, composite Tools, and destruction.
  • Adds select-based Cypress fixtures.
File summaries
File Description
test/cypress/tests/onchange.cy.ts Adds regression and lifecycle tests.
test/cypress/fixtures/tools/SelectTool.ts Adds a basic select fixture.
test/cypress/fixtures/tools/CompositeSelectTool.ts Adds a multi-select fixture.
src/components/block/index.ts Implements select event handling and cleanup.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@neSpecc neSpecc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems ok for me, please, increment a patch version and add a line in a changelog

@Sawtone

Sawtone commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

@neSpecc Done~ bumped the patch version to 2.31.7 and added a changelog entry in df75108. Thanks for reviewing! Thanks @Sion612 for your help as well!

@neSpecc
neSpecc merged commit b847d01 into codex-team:next Sep 17, 2026
4 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.

<select /> not triggering editor.onChange (Old bug resurfaced)

3 participants