Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 28 additions & 15 deletions src/material/button-toggle/button-toggle.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ $fallbacks: m3-button-toggle.get-tokens();
display: inline-flex;
flex-direction: row;
white-space: nowrap;
overflow: hidden;
-webkit-tap-highlight-color: transparent;
border-radius: token-utils.slot(button-toggle-legacy-shape, $fallbacks);

Expand Down Expand Up @@ -82,6 +81,11 @@ $fallbacks: m3-button-toggle.get-tokens();
token-utils.slot(button-toggle-legacy-selected-state-text-color, $fallbacks)};

&.cdk-keyboard-focused .mat-button-toggle-focus-overlay {
outline-width: 3px;
outline-style: solid;
outline-color: var(--sys-secondary);
outline-offset: 3px;
Comment on lines +84 to +87
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be a mixin - I see that there is this mat.strong-focus-indicators mixin ? I may need to defer to @andrewseguin.

z-index: 2;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Do we need this ? I like to avoid z-index if possible.

opacity: token-utils.slot(button-toggle-legacy-focus-state-layer-opacity, $fallbacks);
}

Expand Down Expand Up @@ -356,26 +360,35 @@ $fallbacks: m3-button-toggle.get-tokens();
--mat-focus-indicator-border-radius: #{token-utils.slot(button-toggle-shape, $fallbacks)};
}

.mat-button-toggle-group-appearance-standard:not(.mat-button-toggle-vertical) .mat-button-toggle {
&:last-of-type .mat-button-toggle-button::before {
border-top-right-radius: token-utils.slot(button-toggle-shape, $fallbacks);
border-bottom-right-radius: token-utils.slot(button-toggle-shape, $fallbacks);
.mat-button-toggle-group:not(.mat-button-toggle-vertical) .mat-button-toggle {
&:last-of-type {
.mat-button-toggle-button::before, .mat-button-toggle-ripple {
border-top-right-radius: token-utils.slot(button-toggle-shape, $fallbacks);
border-bottom-right-radius: token-utils.slot(button-toggle-shape, $fallbacks);
}
}

&:first-of-type .mat-button-toggle-button::before {
border-top-left-radius: token-utils.slot(button-toggle-shape, $fallbacks);
border-bottom-left-radius: token-utils.slot(button-toggle-shape, $fallbacks);
&:first-of-type {
.mat-button-toggle-button::before, .mat-button-toggle-ripple {
border-top-left-radius: token-utils.slot(button-toggle-shape, $fallbacks);
border-bottom-left-radius: token-utils.slot(button-toggle-shape, $fallbacks);
}
}
}

.mat-button-toggle-group-appearance-standard.mat-button-toggle-vertical .mat-button-toggle {
&:last-of-type .mat-button-toggle-button::before {
border-bottom-right-radius: token-utils.slot(button-toggle-shape, $fallbacks);
border-bottom-left-radius: token-utils.slot(button-toggle-shape, $fallbacks);
.mat-button-toggle-group.mat-button-toggle-vertical .mat-button-toggle {
&:last-of-type {
.mat-button-toggle-button::before, .mat-button-toggle-ripple {
border-bottom-right-radius: token-utils.slot(button-toggle-shape, $fallbacks);
border-bottom-left-radius: token-utils.slot(button-toggle-shape, $fallbacks);
}
}

&:first-of-type .mat-button-toggle-button::before {
border-top-right-radius: token-utils.slot(button-toggle-shape, $fallbacks);
border-top-left-radius: token-utils.slot(button-toggle-shape, $fallbacks);
&:first-of-type {
.mat-button-toggle-button::before, .mat-button-toggle-ripple {
border-top-right-radius: token-utils.slot(button-toggle-shape, $fallbacks);
border-top-left-radius: token-utils.slot(button-toggle-shape, $fallbacks);
}
}
}

6 changes: 5 additions & 1 deletion src/material/button-toggle/button-toggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,12 @@ export class MatButtonToggleGroup implements ControlValueAccessor, OnInit, After
});

let nextButton: MatButtonToggle | null = null;
let shouldSelect = false;
switch (event.keyCode) {
case SPACE:
case ENTER:
nextButton = this._buttonToggles.get(index) || null;
shouldSelect = true;
break;
case UP_ARROW:
nextButton = this._getNextButton(index, -1);
Expand All @@ -364,7 +366,9 @@ export class MatButtonToggleGroup implements ControlValueAccessor, OnInit, After

if (nextButton) {
event.preventDefault();
nextButton._onButtonClick();
if (shouldSelect) {
nextButton._onButtonClick();
}
nextButton.focus();
}
}
Expand Down