Skip to content

Deactivate menu and clear pending match on disconnect - #101

Open
feritcemkahraman wants to merge 1 commit into
github:mainfrom
feritcemkahraman:fix/deactivate-on-disconnect
Open

feritcemkahraman wants to merge 1 commit into
github:mainfrom
feritcemkahraman:fix/deactivate-on-disconnect

Conversation

@feritcemkahraman

Copy link
Copy Markdown

Summary

  • Clear this.match and call this.deactivate() inside TextExpander#destroy() so disconnecting <text-expander> tears down an open menu, resets combobox ARIA attributes, and ignores late async text-expander-change provider resolutions from the destroyed state.
  • Delete the states entry before calling state.destroy() in disconnectedCallback() so a text-expander-deactivate listener that synchronously reconnects <text-expander> does not have its newly created connectedCallback() state deleted afterward.

Testing

  • npx eslint .
  • npx tsc && npx rollup -c && npx rollup -c rollup.config.test.js
  • npx karma start test/karma.config.cjs (Chromium Headless: 47 passed)
  • Note: Firefox / WebKit browser matrices were not run locally.

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


destroy() {
this.match = null
this.deactivate()

destroy() {
this.match = null
this.deactivate()
Comment on lines +69 to +70
this.match = null
this.deactivate()

This branch has not been deployed

No deployments
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.

2 participants