-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
[Tag] Improve outline behavior #2428
Conversation
add tabIndex for focus on interactive tagsPreview: documentation | landing | table |
@llorca |
@@ -5,10 +5,14 @@ | |||
@import "../forms/common"; | |||
@import "../tag/common"; | |||
|
|||
$ti-padding: ($pt-input-height - $tag-height) / 2; | |||
$tag-input-padding: ($pt-input-height - $tag-height) / 2; |
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.
was a bit confused by the namespace look of $ti
so named this more classicly... if you feel strongly, I can revert back, but this seems more legible to me
@giladgray added a custom outline style for tag input tags only. let me know if that's a fair approach, otherwise could use some help figuring out the best way here |
add custom outline styles for tag input tagsPreview: documentation | landing | table |
// NOTE: in order to wrap long words, you must set explicit width on TagInput, | ||
// or use .#{$ns}-fill CSS class modifier. | ||
overflow-wrap: break-word; | ||
|
||
&::before { |
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.
not a fan of this special case, and even less a fan of not simply using outline
/ the default focus styles (which it used to before this PR)
use focus outline mixin instead of custom box shadowPreview: documentation | landing | table |
fix view source margin bottom by adding a headingPreview: documentation | landing | table |
@@ -88,7 +88,7 @@ export class Tag extends React.PureComponent<ITagProps, {}> { | |||
) : null; | |||
|
|||
return ( | |||
<span {...htmlProps} className={tagClasses}> | |||
<span {...htmlProps} className={tagClasses} tabIndex={interactive ? 0 : -1}> |
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 think we want undefined
in the false case (emphasis mine):
A negative value (usually
tabindex="-1"
) means that the element should be focusable, but should not be reachable via sequential keyboard navigation. Mostly useful to create accessible widgets with JavaScript.
https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex
} | ||
} | ||
|
||
.#{$ns}-tag { | ||
position: relative; |
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.
don't think this chance is necessary. leftover from previous attempt?
// NOTE: in order to wrap long words, you must set explicit width on TagInput, | ||
// or use .#{$ns}-fill CSS class modifier. | ||
overflow-wrap: break-word; | ||
|
||
&.#{$ns}-active { | ||
@include focus-outline(0); |
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.
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 don't think that's the right move, but did it anyway, Not sure what to do with outline design in general
@llorca please merge latest master for the new build steps |
address commentsPreview: documentation | landing | table |
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.
a few more changes. i pushed a commit, so be sure to pull first
$tag-input-icon-padding: ($pt-input-height - $pt-icon-size-standard) / 2; | ||
$tag-input-icon-padding-large: ($pt-input-height-large - $pt-icon-size-large) / 2; | ||
|
||
$tag-input-outline-color: $pt-outline-color; |
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.
remove this alias, use original name directly also unused, please delete.
|
||
$tag-input-outline-color: $pt-outline-color; | ||
$tag-input-outline-offset: 1px; | ||
$tag-input-outline-size: 2px; |
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.
these two vars are unused; please remove
@@ -120,6 +121,7 @@ $tag-padding-large: ($tag-height-large - $pt-icon-size-large) / 2 !default; | |||
background-color: rgba($background-color, $opacity + 0.1); | |||
} | |||
|
|||
&.pt-active, |
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.
#{$ns}
@@ -106,6 +106,7 @@ $tag-padding-large: ($tag-height-large - $pt-icon-size-large) / 2 !default; | |||
background-color: rgba($background-color, $opacity - 0.15); | |||
} | |||
|
|||
&.pt-active, |
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.
pt
⇒ #{$ns}
$ti-icon-padding: ($pt-input-height - $pt-icon-size-standard) / 2; | ||
$ti-icon-padding-large: ($pt-input-height-large - $pt-icon-size-large) / 2; | ||
$tag-input-icon-padding: ($pt-input-height - $pt-icon-size-standard) / 2; | ||
$tag-input-icon-padding-large: ($pt-input-height-large - $pt-icon-size-large) / 2; |
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.
can you add !default
to all these (surviving) vars please?
use tabIndex from props if givenPreview: documentation | landing | table |
Merge branch 'al/tag-outline' of github.com:palantir/blueprint into al/tag-outlinePreview: documentation | landing | table |
@@ -27,6 +27,10 @@ $tag-padding-large: ($tag-height-large - $pt-icon-size-large) / 2 !default; | |||
color: $pt-dark-text-color; | |||
font-size: $pt-font-size-small; | |||
|
|||
&.#{$ns}-active { |
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.
ah dang actually i think this should be &:focus
here, just to adjust the outline-offset.
and bring back this selector in .pt-tag-input .pt-tag
like you had earlier
😄
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.
pushed another commit, hopefully I got it right this time!
address more commentsPreview: documentation | landing | table |
tabIndex
on interactive tags only, for proper keyboard navigation