-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Replace <a>
and <button>
with <PlainButton>
#5433
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
Conversation
e8c4b54
to
282a4dd
Compare
282a4dd
to
c09b5fc
Compare
<a>
and <button>
with <PlainButton>
(part 1)<a>
and <button>
with <PlainButton>
client/app/components/ApplicationArea/ApplicationLayout/DesktopNavbar.jsx
Show resolved
Hide resolved
return ( | ||
<li className={classNames({ done: completed })}> | ||
<Link href={url} onClick={onClick} target={urlTarget}> | ||
<Button type="link" href={url} onClick={onClick} target={urlTarget}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't it change a behavior? We should use Link
component for all internal links
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<Link>
should throw a type error if it gets a click handler. This was sort of a workaround. I'm trying to think in a more general solution to this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<Link>
has some logic that allows to modify URL. Using <Button>
here will break those links in Databricks internal fork
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not agree that link should throw a type error if it gets a click handler.
It's valid to have a link perform one behavior when you click on it, and another if you middle click / open in a new tab (for example, if you want to open a modal, you don't want to refresh the page when you left click, but you do want a new page with the modal if you open a link to it in a new tab).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem in this case is for pieces of code like this:
In practice, this component is sometimes a link and sometimes a button, which hurts its accessibility. If everything were typescript this wouldn't be a problem, as an href
is required by <Link>
. Ideally we would need to have a custom component that renders a <button>
for cases like this one, or add keyboard handlers. Please let me have your opinion on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When Step
component has a link - it can have either urlText
+ onClick
or urlText
+ url
+ urlTarget
. You can use this to decide what to render - link or button. Also, you could even update TS types to indicate this:
type StepCommonProps = { ... };
type StepLinkProps = {
urlText: string;
url: string;
urlTarget: string;
}
type StepButtonProps = {
urlText: string;
onClick: ...;
}
type StepProps = StepCommonProps & (StepLinkProps | StepButtonProps);
In this case when you'll try to render <Step>
component with onClick
- TS will not allow you to use url
and urlTarget
, and if you'll add url
and/or urlTarget
- it will forbid onClick
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update: see #5435
@@ -1,102 +1,107 @@ | |||
div.table-name { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change feels bigger than the others. Can you summarize what the expected changes are to the schema browser?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes expected are basically none. Just refactored the styles to make it easier to work with, as many of the positionings were done in a workaround-like manner. There were bugs as well: I've changed the way tooltips are positioned upon these components to make it a11y (and UI overall) friendly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick summary of the changes:
- Improved nesting
- Decoupled the button to open the drawer with the one that adds it to the editor
- Updated the box sizing to flexbox to achieve the same result more consistently
- Used flexbox to center, in place of paddings and margins
- Reduced repetition re-structuring how classes are set
- Added focus feedback
- Added transition
- TODO (not tracked): render of drawer has no transition
client/app/components/dashboards/dashboard-widget/VisualizationWidget.jsx
Show resolved
Hide resolved
return ( | ||
<li className={classNames({ done: completed })}> | ||
<Link href={url} onClick={onClick} target={urlTarget}> | ||
<Button type="link" href={url} onClick={onClick} target={urlTarget}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not agree that link should throw a type error if it gets a click handler.
It's valid to have a link perform one behavior when you click on it, and another if you middle click / open in a new tab (for example, if you want to open a modal, you don't want to refresh the page when you left click, but you do want a new page with the modal if you open a link to it in a new tab).
fac3015
to
f94a4ba
Compare
|
||
return ( | ||
<li className={classNames({ done: completed })}> | ||
<Button type="link" href={url} onClick={onClick} target={urlTarget}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why Link type="link"
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing blocking. If Percy's happy, so am I! Thanks for doing all this.
f94a4ba
to
6f06d9d
Compare
4431d66
to
8ae04d3
Compare
What type of PR is this? (check all applicable)
Description
This PR is a split on #5409
This PR follows on #5418, #5419, #5420 and #5424
It is the fourth step to fix issues on standardization, interactivity and improve keyboard accessibility.
This aims to clean most remaining
<a>
and<button>
and replace it with own semantic buttons. There should be no visual changes.The following behavior for links, buttons, link-like and button-like components is aimed:
<Link>
- Renders<a>
<Button>
- Renders Antd<Button>
<Link.Button>
- Renders Antd<Button>
, which is rendered as an<a>
<PlainButton>
- Renders styleless<button>
Major visual changes
Before
Kapture.2021-04-06.at.09.51.44.mp4
After
7224edb1c54069a5d9cae94f2c2bb755.mp4