Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Missing "beforetoggle" and "toggle" events on HTMLElement #5963

Closed
3 tasks done
nborelli opened this issue Aug 29, 2024 · 0 comments · Fixed by #5964
Closed
3 tasks done

bug: Missing "beforetoggle" and "toggle" events on HTMLElement #5963

nborelli opened this issue Aug 29, 2024 · 0 comments · Fixed by #5964
Assignees
Labels
Bug: Validated This PR or Issue is verified to be a bug within Stencil

Comments

@nborelli
Copy link

Prerequisites

Stencil Version

4.21.0

Current Behavior

I cannot add an event handler for the beforetoggle or toggle events of any HTMLElement because they do not seem to be defined. See https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/beforetoggle_event. I know the Popover API is relatively new in the DOM, but it is well supported at this point https://caniuse.com/mdn-api_htmlelement_popover.

I get the error:

ts: Type '{ id: string; class: string; popover: string; ref: (el: HTMLElement) => void; onBeforeToggle: (e: ToggleEvent) => void; }' is not assignable to type 'HTMLAttributes<HTMLDivElement>'.
  Property 'onBeforeToggle' does not exist on type 'HTMLAttributes<HTMLDivElement>'.

Expected Behavior

The beforetoggle and toggle events should be defined.

System Info

System: node 22.7.0
    Platform: darwin (23.6.0)
   CPU Model: Apple M3 Max (16 cpus)
    Compiler: /Users/neal.borelli/Code/play/Stencil/popover-poc/node_modules/@stencil/core/compiler/stencil.js
       Build: 1724698030
     Stencil: 4.21.0 🐷
  TypeScript: 5.5.3
      Rollup: 2.56.3
      Parse5: 7.1.2
      jQuery: 4.0.0-pre
      Terser: 5.31.1

Steps to Reproduce

A render() function like this will not work:

  render() {
    return (
      <Host>
        <button popoverTarget="mypopover">Toggle Popover</button>
        <div id="mypopover" popover="auto" onBeforeToggle={this.handleBeforeToggle}>
          <slot />
        </div>
      </Host>
    );
  }

I get the error:

ts: Type '{ id: string; class: string; popover: string; ref: (el: HTMLElement) => void; onBeforeToggle: (e: ToggleEvent) => void; }' is not assignable to type 'HTMLAttributes<HTMLDivElement>'.
  Property 'onBeforeToggle' does not exist on type 'HTMLAttributes<HTMLDivElement>'.

Code Reproduction URL

https://github.com/nborelli/popover-pop-bug

Additional Information

Can work around by using a ref to get the reference to the element and then use addEventListener()

@ionitron-bot ionitron-bot bot added the triage label Aug 29, 2024
@christian-bromann christian-bromann added Bug: Validated This PR or Issue is verified to be a bug within Stencil and removed triage labels Aug 30, 2024
@christian-bromann christian-bromann self-assigned this Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug: Validated This PR or Issue is verified to be a bug within Stencil
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants