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

feat(component): support button as anchor #911

Closed
wants to merge 1 commit into from

Conversation

deini
Copy link
Member

@deini deini commented Jul 12, 2022

What?

Adds support for rendering a button as an anchor.

<Button as="a" href="https://example.com">...

Why?

While we discourage this usage, we have some edge cases where we still need it. Some apps are working around it and we should support their use case.

Screenshots/Screen Recordings

Proper types when changing it to an anchor:

Screenshot 2022-07-12 at 13 53 33@2x

Doesn't allow anchor props by default:
Screenshot 2022-07-12 at 13 55 28@2x

Disallows any other tag:
Screenshot 2022-07-12 at 13 57 00@2x

Caveat:

The disabled prop is not fully supported for anchor tags. It will disable click events but it still tab accessible. While we can support this it's not part of the spec and we probably shouldn't be disabling links. We can revisit this if required in the future.

Testing/Proof

👀 unit test.

Closes #430

@deini deini requested review from a team as code owners July 12, 2022 19:06
@deini deini requested a review from bc-tgomez July 12, 2022 19:06
@deini deini marked this pull request as draft July 12, 2022 19:23
@deini
Copy link
Member Author

deini commented Jul 12, 2022

Closing until TS 4.8

@deini
Copy link
Member Author

deini commented Aug 26, 2022

Additional context, the last missing piece is that the even on things like onClick is reported as any.

TS 4.8 is out but this is still an issue. Try again in the future, this Playground should pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Anchor with Button styles
1 participant