Skip to content
Merged
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
2 changes: 1 addition & 1 deletion goldens/material/core/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export const MATERIAL_ANIMATIONS: InjectionToken<AnimationsConfig>;
export class _MatInternalFormField {
labelPosition: 'before' | 'after';
// (undocumented)
static ɵcmp: i0.ɵɵComponentDeclaration<_MatInternalFormField, "div[mat-internal-form-field]", never, { "labelPosition": { "alias": "labelPosition"; "required": true; }; }, {}, never, ["*"], true, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<_MatInternalFormField, "[mat-internal-form-field]", never, { "labelPosition": { "alias": "labelPosition"; "required": true; }; }, {}, never, ["*"], true, never>;
// (undocumented)
static ɵfac: i0.ɵɵFactoryDeclaration<_MatInternalFormField, never>;
}
Expand Down
1 change: 0 additions & 1 deletion goldens/material/radio/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ export class MatRadioButton implements OnInit, AfterViewInit, DoCheck, OnDestroy
ngOnInit(): void;
_noopAnimations: boolean;
_onInputInteraction(event: Event): void;
_onTouchTargetClick(event: Event): void;
radioGroup: MatRadioGroup;
get required(): boolean;
set required(value: boolean);
Expand Down
12 changes: 8 additions & 4 deletions src/material/core/internal-form-field/internal-form-field.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@
align-items: center;
vertical-align: middle;

& > label {
& > label,
& > .mat-internal-form-field-label {
margin-left: 0;
margin-right: auto;
padding-left: 4px;
padding-right: 0;
order: 0;
}

[dir='rtl'] & > label {
[dir='rtl'] & > label,
[dir='rtl'] & > .mat-internal-form-field-label {
margin-left: auto;
margin-right: 0;
padding-left: 0;
Expand All @@ -23,15 +25,17 @@
}

.mdc-form-field--align-end {
& > label {
& > label,
& > .mat-internal-form-field-label {
margin-left: auto;
margin-right: 0;
padding-left: 0;
padding-right: 4px;
order: -1;
}

[dir='rtl'] .mdc-form-field--align-end & label {
[dir='rtl'] .mdc-form-field--align-end & label,
[dir='rtl'] .mdc-form-field--align-end & .mat-internal-form-field-label {
margin-left: 0;
margin-right: auto;
padding-left: 4px;
Expand Down
3 changes: 1 addition & 2 deletions src/material/core/internal-form-field/internal-form-field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import {Component, Input, ViewEncapsulation} from '@angular/core';
* @docs-private
*/
@Component({
// Use a `div` selector to match the old markup closer.
selector: 'div[mat-internal-form-field]',
selector: '[mat-internal-form-field]',
template: '<ng-content></ng-content>',
styleUrl: 'internal-form-field.css',
encapsulation: ViewEncapsulation.None,
Expand Down
31 changes: 14 additions & 17 deletions src/material/radio/radio.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
<div mat-internal-form-field [labelPosition]="labelPosition" #formField>
<div class="mdc-radio" [class.mdc-radio--disabled]="disabled">
<label mat-internal-form-field [labelPosition]="labelPosition" [for]="inputId" #formField>
<span class="mdc-radio" [class.mdc-radio--disabled]="disabled">
<!-- Render this element first so the input is on top. -->
<div
class="mat-mdc-radio-touch-target"
(click)="_onTouchTargetClick($event)"
aria-hidden="true"></div>
<span class="mat-mdc-radio-touch-target"></span>
<!--
Note that we set `aria-invalid="false"` on the input, because otherwise some screen readers
will read out "required, invalid data" for each radio button that hasn't been checked.
Expand All @@ -25,19 +22,19 @@
[attr.aria-describedby]="ariaDescribedby"
[attr.aria-disabled]="disabled && disabledInteractive ? 'true' : null"
(change)="_onInputInteraction($event)">
<div class="mdc-radio__background" aria-hidden="true">
<div class="mdc-radio__outer-circle"></div>
<div class="mdc-radio__inner-circle"></div>
</div>
<div mat-ripple class="mat-radio-ripple mat-focus-indicator"
<span class="mdc-radio__background" aria-hidden="true">
<span class="mdc-radio__outer-circle"></span>
<span class="mdc-radio__inner-circle"></span>
</span>
<span mat-ripple class="mat-radio-ripple mat-focus-indicator"
[matRippleTrigger]="_rippleTrigger.nativeElement"
[matRippleDisabled]="_isRippleDisabled()"
[matRippleCentered]="true"
aria-hidden="true">
<div class="mat-ripple-element mat-radio-persistent-ripple"></div>
</div>
</div>
<label class="mdc-label" [for]="inputId">
<span class="mat-ripple-element mat-radio-persistent-ripple"></span>
</span>
</span>
<span class="mat-internal-form-field-label mdc-label">
<ng-content></ng-content>
</label>
</div>
</span>
</label>
15 changes: 6 additions & 9 deletions src/material/radio/radio.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,10 @@ $_is-external-build: true;
@include radio-common.radio-structure(true);
@include radio-common.radio-noop-animations();

// Clicking the label toggles the radio, but MDC does not include any styles that inform the
// user of this. Therefore we add the pointer cursor on top of MDC's styles.
label {
cursor: pointer;

// TODO(crisbeto): disable internally due to a large amount of breakages.
// Prevent the label from taking up space when it's empty.
@if ($_is-external-build) {
// TODO(crisbeto): disable internally due to a large amount of breakages.
// Prevent the label from taking up space when it's empty.
@if ($_is-external-build) {
.mat-internal-form-field-label {
&:empty {
display: none;
}
Expand Down Expand Up @@ -51,9 +47,10 @@ $_is-external-build: true;
font-size: token-utils.slot(radio-label-text-size, $fallbacks);
letter-spacing: token-utils.slot(radio-label-text-tracking, $fallbacks);
font-weight: token-utils.slot(radio-label-text-weight, $fallbacks);
cursor: pointer;
}

.mdc-radio--disabled + label {
.mdc-radio--disabled + .mat-internal-form-field-label {
color: token-utils.slot(radio-disabled-label-color, $fallbacks);
}

Expand Down
11 changes: 0 additions & 11 deletions src/material/radio/radio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -709,17 +709,6 @@ export class MatRadioButton implements OnInit, AfterViewInit, DoCheck, OnDestroy
}
}

/** Triggered when the user clicks on the touch target. */
_onTouchTargetClick(event: Event) {
this._onInputInteraction(event);

if (!this.disabled || this.disabledInteractive) {
// Normally the input should be focused already, but if the click
// comes from the touch target, then we might have to focus it ourselves.
this._inputElement?.nativeElement.focus();
}
}

/** Sets the disabled state and marks for check if a change occurred. */
protected _setDisabled(value: boolean) {
if (this._disabled !== value) {
Expand Down
Loading