react icon indicating copy to clipboard operation
react copied to clipboard

Bug: Popover API not supported

Open Semigradsky opened this issue 2 years ago • 7 comments

About this API: https://developer.mozilla.org/en-US/docs/Web/API/Popover_API

React version: any

Steps To Reproduce

      <div popover id="my-popover">
        Greetings, one and all!
      </div>
      <button popovertarget="my-popover" popovertargetaction="show">
        Open Popover
      </button>
      <input
        type="button"
        popovertarget="my-popover"
        popovertargetaction="hide"
        value="Close Popover"
      />

Link to code example: https://codesandbox.io/s/popover-api-8x5nfq?file=/src/App.js

The current behavior

  • Error in console:

    Warning: Received true for a non-boolean attribute popover.

  • popover attribute wasn't added to div

It works if I change boolean atribute popover to popover="yes".

Also ESLint fails on unknown popover, popovertarget, popovertargetaction attributes.

Semigradsky avatar Oct 07 '23 19:10 Semigradsky

Sure

Dreadfullove avatar Oct 08 '23 11:10 Dreadfullove

Related DT discussions:

  • https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/66550
  • https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/66963

Semigradsky avatar Oct 18 '23 08:10 Semigradsky

Login to Svelte REPL is broken if I enable this extension . The authenticating happens in a popup but you can also use it via https://svelte.dev/auth/login . Dev console logs some warnings related to popover API. Is svelte REPL using this API and react dev tools breaking this somehow ?

konstantinblaesi avatar Oct 26 '23 11:10 konstantinblaesi

Hey folks! Any news on this?

A reliable polyfill is available for the Popover API, and some companies (eg. Github) are already using it in production. I tried using it in my app and spent 10 minutes trying to understand what I was doing wrong, before realizing that React itself didn't support it. I think this sort of confusion will only get more common as this API gets more attention.

Just wanted to share this experience since I know it can be hard to gauge the importance of different issues. Appreciate the work y'all do! ❤️

joshwcomeau avatar Apr 10 '24 14:04 joshwcomeau

Just need to bring this up internally so that we're aligned on prop naming. If anybody wants to test it out, you can install

react@https://react-builds.vercel.app/api/prs/27981/packages/react react-dom@https://react-builds.vercel.app/api/prs/27981/packages/react-dom

to test https://github.com/facebook/react/pull/27981

eps1lon avatar Apr 11 '24 20:04 eps1lon

Tried to use popover today. Doesn't work. Have to explicitly set a value despite the spec defining "auto" as default.

Honest question: What is the React team's plan to permanently fix this so developers can trust React will always comply with web standards?

Popover is another example among many throughout the years where React's non-compliance creates friction or outright fails to work with web standards. React has effectively recreated the situation we had with IE where one player with the biggest marketshare slows the whole community down. This is intolerable and not sustainable.

jfbrennan avatar May 17 '24 17:05 jfbrennan

Popover's toggle and beforetoggle events do not appear to work either:

<button popovertarget="myPopover">Toggle</button>
<div onToggle=${handlePopoverToggle} popover="auto" id="myPopover">Popover stuff</div> <-- Does not work

jfbrennan avatar May 17 '24 19:05 jfbrennan

@jfbrennan if you use the latest react RC, all popover API attributes and event handlers are available and working. i'm using

[email protected] [email protected]

acusti avatar May 25 '24 21:05 acusti

Why isn't this added to 18 too? Popover is available in all modern browsers and part of the standard

Screenshot 2024-06-27 at 1 31 01 PM

dominictobias-bullish avatar Jun 27 '24 05:06 dominictobias-bullish

Is there any change the Popover API can be backported to v18?

peteruithoven avatar Jul 27 '24 21:07 peteruithoven

Considering React 19 is delayed, can we not get this in React 18?

teamteak avatar Oct 23 '24 15:10 teamteak

Any news on this? Would be really helpful to use popover. Does anyone knows about a walkaround?

bermann avatar Nov 28 '24 15:11 bermann

@bermann you can use the popover, popovertarget, and popovertargetaction attributes in React 18, though you will need to provide the default auto value to get it to work properly. however, if you want to add a beforetoggle or toggle event listener, you will need to use a ref to add and cleanup the listener manually.

acusti avatar Nov 28 '24 16:11 acusti

bonkers

k-sav avatar Jan 15 '25 06:01 k-sav

It is a shame that this only works if you explicitly use popover="auto" or popover="manual". auto is the default value. In HTML popover attribute works alone without needing to explicitly set it to auto.

o-t-w avatar Jan 17 '25 14:01 o-t-w

Will React18 also support popover api?

tounsoo avatar Feb 18 '25 18:02 tounsoo