question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug]: Popover.Button emits type="button" even when the component isn't a button

See original GitHub issue

What package within Headless UI are you using?

@headlessui/react

What version of that package are you using?

v1.1.0

What browser are you using?

Chrome

Reproduction repository

https://codesandbox.io/s/magical-bash-ij6dg

Describe your issue

Hello headlessui! 👋

This is a really minor issue, but I thought I’d do my due diligence and write it up.

Given this component:

<Popover.Button as="a" href="#">Click Me</Popover.Button>

The emitted HTML is:

<a href="#" type="button">

However, type="button" is not an applicable property for an anchor tag. Ordinarily the extra prop is harmless, but under a perfect storm of unlikely circumstances, it can make a difference. For example, normalize.css uses it as a CSS selector:

[type="button"] {
  -webkit-appearance: button;
}

So this can cause the link to be styled like a button, for instance, in an older version of Chrome (v78). If you try to override the property by adding type={null} or something to the component, your prop is ignored.

This is a really minor issue so I won’t be offended if you think the best course is to just close it and move on, but I think that it would be better if Popover.Button only emitted type="button" when the component tag is the default as="button".

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:9

github_iconTop GitHub Comments

5reactions
RobinMalfaitcommented, Aug 24, 2021

Hey! Thank you for your bug report! Much appreciated! 🙏

This should be fixed, and will be available in the next release.

You can already try it using:

  • npm install @headlessui/react@dev or yarn add @headlessui/react@dev.
  • npm install @headlessui/vue@dev or yarn add @headlessui/vue@dev.
0reactions
arpitjacobcommented, Jul 29, 2021

Have the same issue with

<Disclosure.Button as="div">

it still renders

type="button"

which throws off the css styling

Read more comments on GitHub >

github_iconTop Results From Across the Web

Popover not working with button and input tag - Stack Overflow
Your code is work fine. try this. <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" ...
Read more >
Angular directives for Bootstrap - AngularUI
Each of the components provided in ui-bootstrap have documentation and interactive ... uncheckable B - Whether a radio button can be unchecked or...
Read more >
ion-datetime - Ionic Framework
Ionic's API Datetime input component easily displays a preferred format, ... This component displays buttons which show the current date and time values....
Read more >
Form Input | Components - BootstrapVue
Create various type inputs such as: text, password, number, url, email, search, range, date and more.
Read more >
Safari Technology Preview Release Notes - Apple Developer
Note: Shared Tab Groups and syncing for Tab Groups, Website Settings, and Web Extensions are not enabled in this release. WebAssembly. Fixed error...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found