Skip to content

Deactivate menu and clear pending match on disconnect - #101

Merged
tay1orjones merged 4 commits into
github:mainfrom
feritcemkahraman:fix/deactivate-on-disconnect
Oct 23, 2026
Merged

tay1orjones merged 4 commits into
github:mainfrom
feritcemkahraman:fix/deactivate-on-disconnect

Conversation

@feritcemkahraman

@feritcemkahraman feritcemkahraman commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Disconnecting a <text-expander> closes its menu, clears combobox ARIA state and ignores pending provider results. Cleanup also supports synchronous event handlers that remove or reconnect the element.

Detach old input handlers before deactivation, clear menu/combobox references before notifying listeners, and stop activation when its state or menu was destroyed. Delete the old element state before cleanup so reconnection can keep its replacement state. When replacing a menu, check the instance again after deactivation so an old instance cannot install an orphaned menu.

Validation: the disconnect regressions failed before the initial fix. Reentrant teardown and duplicate input handling also reproduced failures, and removing the activation guard reproduced a rejected start() call. Two menu replacement regressions additionally failed when deactivation disconnected or reconnected the element. All 52 Chromium tests now pass, as do full ESLint, TypeScript, Rollup library and test builds. An external IPv4 Karma configuration avoided a local browser capture timeout; Firefox and WebKit were not run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Disconnect cleanup remains unsafe during synchronous event callbacks.

3 open issues
What changed in this PR

Improves <text-expander> disconnect cleanup and preserves replacement state during reconnection.

Changes:

  • Clear pending matches and deactivate open menus during teardown.
  • Delete disconnected state before cleanup callbacks run.
  • Add disconnect, reconnection, and delayed-provider regression tests.
File Description
test/​text-expander-element-test.js Adds lifecycle cleanup regression tests.
src/​text-expander-element.ts Updates teardown and state-deletion order.

Review effort: Max

Comment thread src/text-expander-element.ts Outdated
Comment thread src/text-expander-element.ts Outdated
Comment thread src/text-expander-element.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Menu replacement can still resume activation on a destroyed instance after a deactivation listener disconnects the element.

1 open issue
3 resolved since last review

Review effort: Max

Comment thread src/text-expander-element.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The public deactivation behavior and reentrant lifecycle changes warrant maintainer review, with browser validation limited to Chromium.

No open issues 🎉

1 resolved since last review

Review effort: Max

@tay1orjones
tay1orjones merged commit d656682 into github:main Oct 23, 2026
2 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.

3 participants