Skip to content

Commit 030cdd6

Browse files
committed
refactor(material/core): allow option parent's disableRipple to be a signal
Expands the `MatOptionParentComponent` to allow the `disableRipple` to be a signal. This will be relevant in the time picker.
1 parent 54ae0b2 commit 030cdd6

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

src/material/core/option/option-parent.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import {InjectionToken} from '@angular/core';
9+
import {InjectionToken, Signal} from '@angular/core';
1010

1111
/**
1212
* Describes a parent component that manages a list of options.
1313
* Contains properties that the options can inherit.
1414
* @docs-private
1515
*/
1616
export interface MatOptionParentComponent {
17-
disableRipple?: boolean;
17+
disableRipple?: boolean | Signal<boolean>;
1818
multiple?: boolean;
1919
inertGroups?: boolean;
2020
hideSingleSelectionIndicator?: boolean;

src/material/core/option/option.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import {
2323
ViewChild,
2424
booleanAttribute,
2525
inject,
26+
isSignal,
27+
Signal,
2628
} from '@angular/core';
2729
import {Subject} from 'rxjs';
2830
import {MAT_OPTGROUP, MatOptgroup} from './optgroup';
@@ -87,6 +89,7 @@ export class MatOption<T = any> implements FocusableOption, AfterViewChecked, On
8789
private _parent = inject<MatOptionParentComponent>(MAT_OPTION_PARENT_COMPONENT, {optional: true});
8890
group = inject<MatOptgroup>(MAT_OPTGROUP, {optional: true});
8991

92+
private _signalDisableRipple = false;
9093
private _selected = false;
9194
private _active = false;
9295
private _disabled = false;
@@ -119,7 +122,9 @@ export class MatOption<T = any> implements FocusableOption, AfterViewChecked, On
119122

120123
/** Whether ripples for the option are disabled. */
121124
get disableRipple(): boolean {
122-
return !!(this._parent && this._parent.disableRipple);
125+
return this._signalDisableRipple
126+
? (this._parent!.disableRipple as Signal<boolean>)()
127+
: !!this._parent?.disableRipple;
123128
}
124129

125130
/** Whether to display checkmark for single-selection. */
@@ -138,7 +143,9 @@ export class MatOption<T = any> implements FocusableOption, AfterViewChecked, On
138143
readonly _stateChanges = new Subject<void>();
139144

140145
constructor(...args: unknown[]);
141-
constructor() {}
146+
constructor() {
147+
this._signalDisableRipple = !!this._parent && isSignal(this._parent.disableRipple);
148+
}
142149

143150
/**
144151
* Whether or not the option is currently active and ready to be selected.

tools/public_api_guard/material/core.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { OnInit } from '@angular/core';
2525
import { Platform } from '@angular/cdk/platform';
2626
import { Provider } from '@angular/core';
2727
import { QueryList } from '@angular/core';
28+
import { Signal } from '@angular/core';
2829
import { Subject } from 'rxjs';
2930
import { Version } from '@angular/core';
3031

@@ -295,7 +296,7 @@ export class MatOptionModule {
295296
// @public
296297
export interface MatOptionParentComponent {
297298
// (undocumented)
298-
disableRipple?: boolean;
299+
disableRipple?: boolean | Signal<boolean>;
299300
// (undocumented)
300301
hideSingleSelectionIndicator?: boolean;
301302
// (undocumented)

0 commit comments

Comments
 (0)