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
fix(button/button-group): styles updates #1117
base: master
Are you sure you want to change the base?
Conversation
Fluent Button Group Bootstrap Material Same issue in Buttons for all themes. Everything else looks good. |
Button Group
|
Does this PR require the addition of new properties to the button components? Can this be accomplished using only :focus and :focus-visible, or is there something I'm overlooking? |
We need this new property to remove the focus styles after clicking on the button which cannot be achieved only using :focus and :focus-visible. The same approach is used in the switch/checkbox/radio components. |
I still believe it's feasible to attain the same functionality using only CSS pseudo-selectors, unless my understanding of the specification is incorrect. The introduction of :focus-visible, which allows different styling based on "browser heuristics" — typically the distinction between pointer and keyboard-driven focus — supports this notion. In my experimentation with the toggle button, it appears to exhibit identical behavior after removing the extra JavaScript properties, the focused DOM element part, and its references in the Fluent style file, along with implementing the subsequent modifications to the Fluent styles: :host {
[part='toggle'] {
min-height: $fluent-flat-btn-size;
border-width: $group-item-border-thickness;
}
[part='toggle']:focus {
background: var-get($theme, 'item-background');
}
[part='toggle']:focus-visible {
background: var-get($theme, 'item-background');
&::after {
content: '';
position: absolute;
inset-block-start: $outline-btn-indent;
inset-inline-start: $outline-btn-indent;
pointer-events: none;
width: calc(100% - (#{$outline-btn-indent} * 2));
height: calc(100% - (#{$outline-btn-indent} * 2));
box-shadow: 0 0 0 rem(1px) var-get($theme, 'item-focused-border-color');
}
}
} As I'm not well-versed in CSS, I'm uncertain about the ease, scalability, and applicability of this approach to our component library, so I will limit my comments to the JavaScript aspects. We should consider if it's possible to simplify the implementation of these behaviors without relying on additional JavaScript code. |
Yeah, you are correct in your assessment and we are aware of the focus-visible pseudo selector and we're using it extensively wherever we can. I believe there were some issues that couldn't be overcome by simply using it in the case of the button, but Silvia can expand on that. |
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.
Avoid exposing additional public APIs for internal states when possible. This approach should accomplish the desired behavior without introducing a new public property.
@state() | ||
public focused = false; |
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.
@state() | |
public focused = false; | |
@state() | |
protected focused = false; |
@@ -171,6 +171,7 @@ export default class IgcButtonGroupComponent extends EventEmitterMixin< | |||
); | |||
|
|||
if (button) { | |||
button.focused = false; |
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.
button.focused = false; | |
Object.assign(button, { focused: false }); |
@rkaraivanov We have different focus styles depending on if the button is focused via keyboard or mouse click. If you focus a button using keyboard and then click on it with the mouse, the "keyboard focus styles" should be removed. Here is an example with the suggested CSS code: Screen.Recording.2024-04-30.at.1.01.12.AM.movAs you can see, the focus-visible box-shadow remains visible. The same thing goes for the button component. |
Button Group Material & Fluent:
Bootstrap:
Indigo:
|
This comment was marked as resolved.
This comment was marked as resolved.
From our side, everything looks fine, and all comments for Material, Fluent and Bootstrap are implemented. |
INDIGO THEME I will just list the correct left and right paddings here:
Like @AnjiManova said, the medium size is correctly implemented. The other 2 need to be fixed. |
The comments for Indigo Theme were implemented. So looks good to me! ✅✅✅ |
Closes #1107