Skip to content

Commit 2482699

Browse files
author
DevBot
committed
fix(search): fix JSX onClick by removing double signal binding
Root cause: class={this.#overlayClass} in render reads a computed signal, triggering full re-render when the overlay opens/closes. This recreates the overlay DOM element, losing the JSX onClick handler (attached via addEventListener in applyProps). Fix: use static class='overlay' and rely solely on data-signal-attr='class' for dynamic updates. This avoids full re-render and preserves the click handler across open/close transitions. Also reverts the connectedCallback addEventListener workaround — no longer needed since the VNode onClick handler works correctly with this fix. Verification: - deno task test: 894 passed, 0 failed - e2e chromium: 25/25 passed (search + theme + i18n) - autoflow:push: 4/4 PASS
1 parent 6ca5031 commit 2482699

1 file changed

Lines changed: 1 addition & 6 deletions

File tree

www/app/islands/open-search.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,6 @@ export default class OpenSearch extends OpenElement {
215215
override connectedCallback(): void {
216216
super.connectedCallback();
217217
globalThis.addEventListener('keydown', this._onKeydown);
218-
// ponytail: VNode onClick delegation does not reliably fire on shadow DOM
219-
// children in all browsers. Attach a native click listener directly.
220-
this.shadowRoot
221-
?.querySelector('.overlay')
222-
?.addEventListener('click', (e: Event) => this._closeOnBackdrop(e));
223218
}
224219

225220
override disconnectedCallback(): void {
@@ -369,7 +364,7 @@ export default class OpenSearch extends OpenElement {
369364
</button>
370365

371366
<div
372-
class={this.#overlayClass}
367+
class='overlay'
373368
data-signal='overlayClass'
374369
data-signal-attr='class'
375370
onClick={(e: Event) => this._closeOnBackdrop(e)}

0 commit comments

Comments
 (0)