Skip to content

[Button] disabled attribute is not allowed on element a #757

@kaelig

Description

@kaelig

Issue summary

A disabled button renders invalid markup when passed a URL prop:

<Button disabled={true} url="https://foo.com">Add product</Button>

Expected behavior

HTML is valid, without a disabled attribute on the anchor element:

<a class="Polaris-Button Polaris-Button--disabled" href="https://foo.com" data-polaris-unstyled="true"><span class="Polaris-Button__Content"><span>Add product</span></span></a>

Actual behavior

HTML is invalid (Error: Attribute disabled not allowed on element a at this point):

<a class="Polaris-Button Polaris-Button--disabled" disabled="" href="https://foo.com" data-polaris-unstyled="true"><span class="Polaris-Button__Content"><span>Add product</span></span></a>

diff:

- <a class="Polaris-Button Polaris-Button--disabled" disabled="" href="https://foo.com"
+ <a class="Polaris-Button Polaris-Button--disabled" href="https://foo.com"

Steps to reproduce the problem

  1. Go to https://codesandbox.io/s/nrz4zwlnqj?module=App.js
  2. Look at the rendered markup
  3. Validate markup against https://validator.w3.org/nu/#textarea

Specifications

  • Polaris version number: 3.3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething is broken and not working as intended in the system.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions