Skip to content

fix(multiple): resolve directive host binding issues #30606

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

Merged
merged 1 commit into from
Mar 11, 2025
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
5 changes: 3 additions & 2 deletions src/material/autocomplete/autocomplete-trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,8 @@ export class MatAutocompleteTrigger
this._element.nativeElement.disabled = isDisabled;
}

_handleKeydown(event: KeyboardEvent): void {
_handleKeydown(e: Event): void {
const event = e as KeyboardEvent;
const keyCode = event.keyCode;
const hasModifier = hasModifierKey(event);

Expand Down Expand Up @@ -501,7 +502,7 @@ export class MatAutocompleteTrigger
}
}

_handleInput(event: KeyboardEvent): void {
_handleInput(event: Event): void {
let target = event.target as HTMLInputElement;
let value: number | string | null = target.value;

Expand Down
2 changes: 1 addition & 1 deletion src/material/chips/chip-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class MatChipInput implements MatChipTextControl, OnChanges, OnDestroy {
this._chipGrid.registerInput(this);
}
}
private _chipGrid: MatChipGrid;
protected _chipGrid: MatChipGrid;

/**
* Whether or not the chipEnd event will be emitted when the input is blurred.
Expand Down
24 changes: 10 additions & 14 deletions src/material/datepicker/date-range-input-parts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ abstract class MatDateRangeInputPartBase<D>
}

/** Handles `input` events on the input element. */
override _onInput(value: string) {
super._onInput(value);
override _onInput(event: Event) {
super._onInput(event);
this._rangeInput._handleChildValueChange();
}

Expand Down Expand Up @@ -211,15 +211,13 @@ abstract class MatDateRangeInputPartBase<D>
host: {
'class': 'mat-start-date mat-date-range-input-inner',
'[disabled]': 'disabled',
'(input)': '_onInput($event.target.value)',
'(input)': '_onInput($event)',
'(change)': '_onChange()',
'(keydown)': '_onKeydown($event)',
'[attr.aria-haspopup]': '_rangeInput.rangePicker ? "dialog" : null',
'[attr.aria-owns]': `_rangeInput._ariaOwns
? _rangeInput._ariaOwns()
: (_rangeInput.rangePicker?.opened && _rangeInput.rangePicker.id) || null`,
'[attr.min]': '_getMinDate() ? _dateAdapter.toIso8601(_getMinDate()) : null',
'[attr.max]': '_getMaxDate() ? _dateAdapter.toIso8601(_getMaxDate()) : null',
'[attr.aria-owns]': '_rangeInput._ariaOwns() || null',
'[attr.min]': '_getMinDate() ? _dateAdapter.toIso8601(_getMinDate()!) : null',
'[attr.max]': '_getMaxDate() ? _dateAdapter.toIso8601(_getMaxDate()!) : null',
'(blur)': '_onBlur()',
'type': 'text',
},
Expand Down Expand Up @@ -301,15 +299,13 @@ export class MatStartDate<D> extends MatDateRangeInputPartBase<D> {
host: {
'class': 'mat-end-date mat-date-range-input-inner',
'[disabled]': 'disabled',
'(input)': '_onInput($event.target.value)',
'(input)': '_onInput($event)',
'(change)': '_onChange()',
'(keydown)': '_onKeydown($event)',
'[attr.aria-haspopup]': '_rangeInput.rangePicker ? "dialog" : null',
'[attr.aria-owns]': `_rangeInput._ariaOwns
? _rangeInput._ariaOwns()
: (_rangeInput.rangePicker?.opened && _rangeInput.rangePicker.id) || null`,
'[attr.min]': '_getMinDate() ? _dateAdapter.toIso8601(_getMinDate()) : null',
'[attr.max]': '_getMaxDate() ? _dateAdapter.toIso8601(_getMaxDate()) : null',
'[attr.aria-owns]': '_rangeInput._ariaOwns() || null',
'[attr.min]': '_getMinDate() ? _dateAdapter.toIso8601(_getMinDate()!) : null',
'[attr.max]': '_getMaxDate() ? _dateAdapter.toIso8601(_getMaxDate()!) : null',
'(blur)': '_onBlur()',
'type': 'text',
},
Expand Down
3 changes: 2 additions & 1 deletion src/material/datepicker/datepicker-input-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,8 @@ export abstract class MatDatepickerInputBase<S, D = ExtractDateTypeFromSelection
}
}

_onInput(value: string) {
_onInput(event: Event) {
const value = (event.target as HTMLInputElement).value;
const lastValueWasValid = this._lastValueValid;
let date = this._dateAdapter.parse(value, this._dateFormats.parse.dateInput);
this._lastValueValid = this._isValidValue(date);
Expand Down
2 changes: 1 addition & 1 deletion src/material/datepicker/datepicker-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const MAT_DATEPICKER_VALIDATORS: any = {
// `aria-owns` for this, because it's only defined while the calendar is open.
'[attr.data-mat-calendar]': '_datepicker ? _datepicker.id : null',
'[disabled]': 'disabled',
'(input)': '_onInput($event.target.value)',
'(input)': '_onInput($event)',
'(change)': '_onChange()',
'(blur)': '_onBlur()',
'(keydown)': '_onKeydown($event)',
Expand Down
2 changes: 1 addition & 1 deletion src/material/menu/menu-trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const PANELS_TO_TRIGGERS = new WeakMap<MatMenuPanel, MatMenuTrigger>();
'class': 'mat-mdc-menu-trigger',
'[attr.aria-haspopup]': 'menu ? "menu" : null',
'[attr.aria-expanded]': 'menuOpen',
'[attr.aria-controls]': 'menuOpen ? menu.panelId : null',
'[attr.aria-controls]': 'menuOpen ? menu?.panelId : null',
'(click)': '_handleClick($event)',
'(mousedown)': '_handleMousedown($event)',
'(keydown)': '_handleKeydown($event)',
Expand Down
5 changes: 3 additions & 2 deletions src/material/timepicker/timepicker-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ import {DOCUMENT} from '@angular/common';
'[attr.mat-timepicker-id]': 'timepicker()?.panelId',
'[disabled]': 'disabled()',
'(blur)': '_handleBlur()',
'(input)': '_handleInput($event.target.value)',
'(input)': '_handleInput($event)',
'(keydown)': '_handleKeydown($event)',
},
providers: [
Expand Down Expand Up @@ -261,7 +261,8 @@ export class MatTimepickerInput<D> implements ControlValueAccessor, Validator, O
};

/** Handles the `input` event. */
protected _handleInput(value: string) {
protected _handleInput(event: Event) {
const value = (event.target as HTMLInputElement).value;
const currentValue = this.value();
const date = this._dateAdapter.parseTime(value, this._dateFormats.parse.timeInput);
const hasChanged = !this._dateAdapter.sameTime(date, currentValue);
Expand Down
4 changes: 2 additions & 2 deletions tools/public_api_guard/material/autocomplete.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ export class MatAutocompleteTrigger implements ControlValueAccessor, AfterViewIn
// (undocumented)
_handleFocus(): void;
// (undocumented)
_handleInput(event: KeyboardEvent): void;
_handleInput(event: Event): void;
// (undocumented)
_handleKeydown(event: KeyboardEvent): void;
_handleKeydown(e: Event): void;
// (undocumented)
static ngAcceptInputType_autocompleteDisabled: unknown;
// (undocumented)
Expand Down
2 changes: 2 additions & 0 deletions tools/public_api_guard/material/chips.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ export class MatChipInput implements MatChipTextControl, OnChanges, OnDestroy {
readonly chipEnd: EventEmitter<MatChipInputEvent>;
get chipGrid(): MatChipGrid;
set chipGrid(value: MatChipGrid);
// (undocumented)
protected _chipGrid: MatChipGrid;
clear(): void;
get disabled(): boolean;
set disabled(value: boolean);
Expand Down
2 changes: 1 addition & 1 deletion tools/public_api_guard/material/timepicker.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class MatTimepickerInput<D> implements ControlValueAccessor, Validator, O
_getLabelId(): string | null;
getOverlayOrigin(): ElementRef<HTMLElement>;
protected _handleBlur(): void;
protected _handleInput(value: string): void;
protected _handleInput(event: Event): void;
protected _handleKeydown(event: KeyboardEvent): void;
readonly max: InputSignalWithTransform<D | null, unknown>;
readonly min: InputSignalWithTransform<D | null, unknown>;
Expand Down
Loading