@angular/material 17.2.0 → 17.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/autocomplete/index.d.ts +5 -0
- package/core/index.d.ts +57 -13
- package/core/theming/_inspection.scss +2 -2
- package/core/tokens/_token-utils.scss +3 -0
- package/core/tokens/m2/mat/_datepicker.scss +1 -2
- package/core/tokens/m2/mat/_expansion.scss +2 -0
- package/core/tokens/m2/mat/_fab-small.scss +30 -13
- package/core/tokens/m2/mat/_fab.scss +30 -13
- package/core/tokens/m2/mat/_filled-button.scss +22 -10
- package/core/tokens/m2/mat/_form-field.scss +5 -5
- package/core/tokens/m2/mat/_icon-button.scss +3 -4
- package/core/tokens/m2/mat/_menu.scss +2 -2
- package/core/tokens/m2/mat/_option.scss +2 -2
- package/core/tokens/m2/mat/_outlined-button.scss +3 -4
- package/core/tokens/m2/mat/_protected-button.scss +22 -10
- package/core/tokens/m2/mat/_radio.scss +1 -3
- package/core/tokens/m2/mat/_select.scss +17 -7
- package/core/tokens/m2/mat/_switch.scss +1 -0
- package/core/tokens/m2/mat/_tab-header.scss +2 -2
- package/core/tokens/m2/mat/_text-button.scss +3 -4
- package/core/tokens/m2/mdc/_checkbox.scss +14 -12
- package/core/tokens/m2/mdc/_chip.scss +3 -9
- package/core/tokens/m2/mdc/_dialog.scss +9 -3
- package/core/tokens/m2/mdc/_filled-button.scss +19 -9
- package/core/tokens/m2/mdc/_filled-text-field.scss +22 -10
- package/core/tokens/m2/mdc/_outlined-button.scss +12 -8
- package/core/tokens/m2/mdc/_outlined-text-field.scss +21 -10
- package/core/tokens/m2/mdc/_protected-button.scss +18 -7
- package/core/tokens/m2/mdc/_radio.scss +4 -5
- package/core/tokens/m2/mdc/_text-button.scss +3 -3
- package/datepicker/index.d.ts +1 -0
- package/esm2022/autocomplete/autocomplete-trigger.mjs +34 -19
- package/esm2022/autocomplete/autocomplete.mjs +3 -3
- package/esm2022/badge/badge.mjs +1 -1
- package/esm2022/bottom-sheet/bottom-sheet-container.mjs +1 -1
- package/esm2022/button/fab.mjs +1 -1
- package/esm2022/button-toggle/button-toggle.mjs +1 -1
- package/esm2022/card/card.mjs +1 -1
- package/esm2022/checkbox/checkbox.mjs +1 -1
- package/esm2022/chips/chip-grid.mjs +1 -1
- package/esm2022/chips/chip-listbox.mjs +1 -1
- package/esm2022/chips/chip-option.mjs +1 -1
- package/esm2022/chips/chip-row.mjs +1 -1
- package/esm2022/chips/chip-set.mjs +1 -1
- package/esm2022/chips/chip.mjs +1 -1
- package/esm2022/core/common-behaviors/color.mjs +1 -1
- package/esm2022/core/common-behaviors/disable-ripple.mjs +1 -1
- package/esm2022/core/common-behaviors/disabled.mjs +1 -1
- package/esm2022/core/common-behaviors/error-state.mjs +1 -1
- package/esm2022/core/common-behaviors/initialized.mjs +6 -2
- package/esm2022/core/common-behaviors/tabindex.mjs +1 -1
- package/esm2022/core/internal-form-field/internal-form-field.mjs +1 -1
- package/esm2022/core/option/optgroup.mjs +1 -1
- package/esm2022/core/option/option.mjs +1 -1
- package/esm2022/core/selection/pseudo-checkbox/pseudo-checkbox.mjs +1 -1
- package/esm2022/core/version.mjs +1 -1
- package/esm2022/datepicker/calendar-body.mjs +1 -1
- package/esm2022/datepicker/calendar.mjs +5 -5
- package/esm2022/datepicker/date-range-input-parts.mjs +11 -6
- package/esm2022/datepicker/date-range-input.mjs +1 -1
- package/esm2022/datepicker/datepicker-actions.mjs +1 -1
- package/esm2022/datepicker/datepicker-base.mjs +1 -1
- package/esm2022/datepicker/datepicker-toggle.mjs +1 -1
- package/esm2022/dialog/dialog-container.mjs +1 -1
- package/esm2022/divider/divider.mjs +1 -1
- package/esm2022/expansion/expansion-panel-header.mjs +3 -3
- package/esm2022/expansion/expansion-panel.mjs +35 -25
- package/esm2022/form-field/form-field.mjs +3 -3
- package/esm2022/grid-list/grid-list.mjs +1 -1
- package/esm2022/grid-list/grid-tile.mjs +1 -1
- package/esm2022/icon/icon.mjs +1 -1
- package/esm2022/list/action-list.mjs +1 -1
- package/esm2022/list/list-option.mjs +3 -3
- package/esm2022/list/list.mjs +1 -1
- package/esm2022/list/nav-list.mjs +1 -1
- package/esm2022/list/selection-list.mjs +1 -1
- package/esm2022/menu/menu.mjs +1 -1
- package/esm2022/paginator/paginator.mjs +14 -13
- package/esm2022/progress-bar/progress-bar.mjs +1 -1
- package/esm2022/progress-spinner/progress-spinner.mjs +1 -1
- package/esm2022/radio/radio.mjs +1 -1
- package/esm2022/select/select.mjs +15 -8
- package/esm2022/sidenav/drawer.mjs +1 -1
- package/esm2022/sidenav/sidenav.mjs +1 -1
- package/esm2022/slide-toggle/slide-toggle.mjs +3 -3
- package/esm2022/slider/slider-thumb.mjs +1 -1
- package/esm2022/slider/slider.mjs +1 -1
- package/esm2022/snack-bar/simple-snack-bar.mjs +1 -1
- package/esm2022/snack-bar/snack-bar-container.mjs +1 -1
- package/esm2022/sort/sort-header.mjs +1 -1
- package/esm2022/sort/sort.mjs +9 -11
- package/esm2022/stepper/step-header.mjs +1 -1
- package/esm2022/stepper/stepper.mjs +1 -1
- package/esm2022/table/cell.mjs +2 -3
- package/esm2022/table/row.mjs +16 -7
- package/esm2022/table/table.mjs +1 -1
- package/esm2022/table/text-column.mjs +2 -2
- package/esm2022/tabs/ink-bar.mjs +87 -88
- package/esm2022/tabs/tab-body.mjs +1 -1
- package/esm2022/tabs/tab-group.mjs +2 -2
- package/esm2022/tabs/tab-header.mjs +1 -1
- package/esm2022/tabs/tab-label-wrapper.mjs +4 -9
- package/esm2022/tabs/tab-nav-bar/tab-nav-bar.mjs +3 -6
- package/esm2022/toolbar/toolbar.mjs +1 -1
- package/esm2022/tooltip/tooltip.mjs +1 -1
- package/esm2022/tree/node.mjs +2 -2
- package/esm2022/tree/toggle.mjs +2 -2
- package/esm2022/tree/tree.mjs +1 -1
- package/expansion/index.d.ts +5 -2
- package/fesm2022/autocomplete.mjs +36 -21
- package/fesm2022/autocomplete.mjs.map +1 -1
- package/fesm2022/badge.mjs.map +1 -1
- package/fesm2022/bottom-sheet.mjs.map +1 -1
- package/fesm2022/button-toggle.mjs.map +1 -1
- package/fesm2022/button.mjs.map +1 -1
- package/fesm2022/card.mjs.map +1 -1
- package/fesm2022/checkbox.mjs.map +1 -1
- package/fesm2022/chips.mjs.map +1 -1
- package/fesm2022/core.mjs +6 -2
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/datepicker.mjs +14 -9
- package/fesm2022/datepicker.mjs.map +1 -1
- package/fesm2022/dialog.mjs.map +1 -1
- package/fesm2022/divider.mjs.map +1 -1
- package/fesm2022/expansion.mjs +36 -26
- package/fesm2022/expansion.mjs.map +1 -1
- package/fesm2022/form-field.mjs +2 -2
- package/fesm2022/form-field.mjs.map +1 -1
- package/fesm2022/grid-list.mjs.map +1 -1
- package/fesm2022/icon.mjs.map +1 -1
- package/fesm2022/list.mjs +2 -2
- package/fesm2022/list.mjs.map +1 -1
- package/fesm2022/menu.mjs.map +1 -1
- package/fesm2022/paginator.mjs +12 -12
- package/fesm2022/paginator.mjs.map +1 -1
- package/fesm2022/progress-bar.mjs.map +1 -1
- package/fesm2022/progress-spinner.mjs.map +1 -1
- package/fesm2022/radio.mjs.map +1 -1
- package/fesm2022/select.mjs +11 -4
- package/fesm2022/select.mjs.map +1 -1
- package/fesm2022/sidenav.mjs.map +1 -1
- package/fesm2022/slide-toggle.mjs +2 -2
- package/fesm2022/slide-toggle.mjs.map +1 -1
- package/fesm2022/slider.mjs.map +1 -1
- package/fesm2022/snack-bar.mjs.map +1 -1
- package/fesm2022/sort.mjs +9 -10
- package/fesm2022/sort.mjs.map +1 -1
- package/fesm2022/stepper.mjs.map +1 -1
- package/fesm2022/table.mjs +17 -9
- package/fesm2022/table.mjs.map +1 -1
- package/fesm2022/tabs.mjs +90 -100
- package/fesm2022/tabs.mjs.map +1 -1
- package/fesm2022/toolbar.mjs.map +1 -1
- package/fesm2022/tooltip.mjs.map +1 -1
- package/fesm2022/tree.mjs +2 -2
- package/fesm2022/tree.mjs.map +1 -1
- package/form-field/_mdc-text-field-structure-overrides.scss +16 -0
- package/package.json +2 -2
- package/paginator/index.d.ts +6 -8
- package/prebuilt-themes/deeppurple-amber.css +1 -1
- package/prebuilt-themes/indigo-pink.css +1 -1
- package/prebuilt-themes/pink-bluegrey.css +1 -1
- package/prebuilt-themes/purple-green.css +1 -1
- package/schematics/ng-add/index.js +1 -1
- package/schematics/ng-add/index.mjs +1 -1
- package/schematics/ng-add/setup-project.js +21 -6
- package/schematics/ng-add/setup-project.mjs +21 -6
- package/schematics/ng-add/theming/create-custom-theme.js +4 -2
- package/schematics/ng-add/theming/create-custom-theme.mjs +4 -2
- package/select/index.d.ts +7 -2
- package/sort/index.d.ts +5 -7
- package/table/index.d.ts +3 -1
- package/tabs/index.d.ts +31 -16
|
@@ -7,7 +7,7 @@ import * as i3 from '@angular/cdk/scrolling';
|
|
|
7
7
|
import { CdkScrollableModule } from '@angular/cdk/scrolling';
|
|
8
8
|
import * as i1$1 from '@angular/cdk/overlay';
|
|
9
9
|
import { Overlay, OverlayConfig, OverlayModule } from '@angular/cdk/overlay';
|
|
10
|
-
import { ActiveDescendantKeyManager,
|
|
10
|
+
import { ActiveDescendantKeyManager, removeAriaReferencedId, addAriaReferencedId } from '@angular/cdk/a11y';
|
|
11
11
|
import { coerceStringArray } from '@angular/cdk/coercion';
|
|
12
12
|
import * as i1 from '@angular/cdk/platform';
|
|
13
13
|
import { _getEventTarget } from '@angular/cdk/platform';
|
|
@@ -228,13 +228,13 @@ class MatAutocomplete {
|
|
|
228
228
|
return false;
|
|
229
229
|
}
|
|
230
230
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.0", ngImport: i0, type: MatAutocomplete, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: MAT_AUTOCOMPLETE_DEFAULT_OPTIONS }, { token: i1.Platform }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
231
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "16.1.0", version: "17.2.0", type: MatAutocomplete, isStandalone: true, selector: "mat-autocomplete", inputs: { ariaLabel: ["aria-label", "ariaLabel"], ariaLabelledby: ["aria-labelledby", "ariaLabelledby"], displayWith: "displayWith", autoActiveFirstOption: ["autoActiveFirstOption", "autoActiveFirstOption", booleanAttribute], autoSelectActiveOption: ["autoSelectActiveOption", "autoSelectActiveOption", booleanAttribute], requireSelection: ["requireSelection", "requireSelection", booleanAttribute], panelWidth: "panelWidth", disableRipple: ["disableRipple", "disableRipple", booleanAttribute], classList: ["class", "classList"], hideSingleSelectionIndicator: ["hideSingleSelectionIndicator", "hideSingleSelectionIndicator", booleanAttribute] }, outputs: { optionSelected: "optionSelected", opened: "opened", closed: "closed", optionActivated: "optionActivated" }, host: { classAttribute: "mat-mdc-autocomplete" }, providers: [{ provide: MAT_OPTION_PARENT_COMPONENT, useExisting: MatAutocomplete }], queries: [{ propertyName: "options", predicate: MatOption, descendants: true }, { propertyName: "optionGroups", predicate: MAT_OPTGROUP, descendants: true }], viewQueries: [{ propertyName: "template", first: true, predicate: TemplateRef, descendants: true, static: true }, { propertyName: "panel", first: true, predicate: ["panel"], descendants: true }], exportAs: ["matAutocomplete"], ngImport: i0, template: "<ng-template let-formFieldId=\"id\">\n <div\n class=\"mat-mdc-autocomplete-panel mdc-menu-surface mdc-menu-surface--open\"\n role=\"listbox\"\n [id]=\"id\"\n [ngClass]=\"_classList\"\n [attr.aria-label]=\"ariaLabel || null\"\n [attr.aria-labelledby]=\"_getPanelAriaLabelledby(formFieldId)\"\n [@panelAnimation]=\"isOpen ? 'visible' : 'hidden'\"\n (@panelAnimation.done)=\"_animationDone.next($event)\"\n #panel>\n <ng-content></ng-content>\n </div>\n</ng-template>\n", styles: ["div.mat-mdc-autocomplete-panel{width:100%;max-height:256px;visibility:hidden;transform-origin:center top;overflow:auto;padding:8px 0;box-sizing:border-box;position:static;border-radius:var(--mat-autocomplete-container-shape);box-shadow:var(--mat-autocomplete-container-elevation-shadow);background-color:var(--mat-autocomplete-background-color)}.cdk-high-contrast-active div.mat-mdc-autocomplete-panel{outline:solid 1px}.cdk-overlay-pane:not(.mat-mdc-autocomplete-panel-above) div.mat-mdc-autocomplete-panel{border-top-left-radius:0;border-top-right-radius:0}.mat-mdc-autocomplete-panel-above div.mat-mdc-autocomplete-panel{border-bottom-left-radius:0;border-bottom-right-radius:0;transform-origin:center bottom}div.mat-mdc-autocomplete-panel.mat-mdc-autocomplete-visible{visibility:visible}div.mat-mdc-autocomplete-panel.mat-mdc-autocomplete-hidden{visibility:hidden}mat-autocomplete{display:none}"], dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], animations: [panelAnimation], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
|
231
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "16.1.0", version: "17.2.0", type: MatAutocomplete, isStandalone: true, selector: "mat-autocomplete", inputs: { ariaLabel: ["aria-label", "ariaLabel"], ariaLabelledby: ["aria-labelledby", "ariaLabelledby"], displayWith: "displayWith", autoActiveFirstOption: ["autoActiveFirstOption", "autoActiveFirstOption", booleanAttribute], autoSelectActiveOption: ["autoSelectActiveOption", "autoSelectActiveOption", booleanAttribute], requireSelection: ["requireSelection", "requireSelection", booleanAttribute], panelWidth: "panelWidth", disableRipple: ["disableRipple", "disableRipple", booleanAttribute], classList: ["class", "classList"], hideSingleSelectionIndicator: ["hideSingleSelectionIndicator", "hideSingleSelectionIndicator", booleanAttribute] }, outputs: { optionSelected: "optionSelected", opened: "opened", closed: "closed", optionActivated: "optionActivated" }, host: { classAttribute: "mat-mdc-autocomplete" }, providers: [{ provide: MAT_OPTION_PARENT_COMPONENT, useExisting: MatAutocomplete }], queries: [{ propertyName: "options", predicate: MatOption, descendants: true }, { propertyName: "optionGroups", predicate: MAT_OPTGROUP, descendants: true }], viewQueries: [{ propertyName: "template", first: true, predicate: TemplateRef, descendants: true, static: true }, { propertyName: "panel", first: true, predicate: ["panel"], descendants: true }], exportAs: ["matAutocomplete"], ngImport: i0, template: "<ng-template let-formFieldId=\"id\">\n <div\n class=\"mat-mdc-autocomplete-panel mdc-menu-surface mdc-menu-surface--open\"\n role=\"listbox\"\n [id]=\"id\"\n [ngClass]=\"_classList\"\n [attr.aria-label]=\"ariaLabel || null\"\n [attr.aria-labelledby]=\"_getPanelAriaLabelledby(formFieldId)\"\n [@panelAnimation]=\"isOpen ? 'visible' : 'hidden'\"\n (@panelAnimation.done)=\"_animationDone.next($event)\"\n #panel>\n <ng-content></ng-content>\n </div>\n</ng-template>\n", styles: ["div.mat-mdc-autocomplete-panel{width:100%;max-height:256px;visibility:hidden;transform-origin:center top;overflow:auto;padding:8px 0;box-sizing:border-box;position:static;border-radius:var(--mat-autocomplete-container-shape);box-shadow:var(--mat-autocomplete-container-elevation-shadow);background-color:var(--mat-autocomplete-background-color)}.cdk-high-contrast-active div.mat-mdc-autocomplete-panel{outline:solid 1px}.cdk-overlay-pane:not(.mat-mdc-autocomplete-panel-above) div.mat-mdc-autocomplete-panel{border-top-left-radius:0;border-top-right-radius:0}.mat-mdc-autocomplete-panel-above div.mat-mdc-autocomplete-panel{border-bottom-left-radius:0;border-bottom-right-radius:0;transform-origin:center bottom}div.mat-mdc-autocomplete-panel.mat-mdc-autocomplete-visible{visibility:visible}div.mat-mdc-autocomplete-panel.mat-mdc-autocomplete-hidden{visibility:hidden;pointer-events:none}mat-autocomplete{display:none}"], dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], animations: [panelAnimation], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
|
232
232
|
}
|
|
233
233
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.0", ngImport: i0, type: MatAutocomplete, decorators: [{
|
|
234
234
|
type: Component,
|
|
235
235
|
args: [{ selector: 'mat-autocomplete', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, exportAs: 'matAutocomplete', host: {
|
|
236
236
|
'class': 'mat-mdc-autocomplete',
|
|
237
|
-
}, providers: [{ provide: MAT_OPTION_PARENT_COMPONENT, useExisting: MatAutocomplete }], animations: [panelAnimation], standalone: true, imports: [NgClass], template: "<ng-template let-formFieldId=\"id\">\n <div\n class=\"mat-mdc-autocomplete-panel mdc-menu-surface mdc-menu-surface--open\"\n role=\"listbox\"\n [id]=\"id\"\n [ngClass]=\"_classList\"\n [attr.aria-label]=\"ariaLabel || null\"\n [attr.aria-labelledby]=\"_getPanelAriaLabelledby(formFieldId)\"\n [@panelAnimation]=\"isOpen ? 'visible' : 'hidden'\"\n (@panelAnimation.done)=\"_animationDone.next($event)\"\n #panel>\n <ng-content></ng-content>\n </div>\n</ng-template>\n", styles: ["div.mat-mdc-autocomplete-panel{width:100%;max-height:256px;visibility:hidden;transform-origin:center top;overflow:auto;padding:8px 0;box-sizing:border-box;position:static;border-radius:var(--mat-autocomplete-container-shape);box-shadow:var(--mat-autocomplete-container-elevation-shadow);background-color:var(--mat-autocomplete-background-color)}.cdk-high-contrast-active div.mat-mdc-autocomplete-panel{outline:solid 1px}.cdk-overlay-pane:not(.mat-mdc-autocomplete-panel-above) div.mat-mdc-autocomplete-panel{border-top-left-radius:0;border-top-right-radius:0}.mat-mdc-autocomplete-panel-above div.mat-mdc-autocomplete-panel{border-bottom-left-radius:0;border-bottom-right-radius:0;transform-origin:center bottom}div.mat-mdc-autocomplete-panel.mat-mdc-autocomplete-visible{visibility:visible}div.mat-mdc-autocomplete-panel.mat-mdc-autocomplete-hidden{visibility:hidden}mat-autocomplete{display:none}"] }]
|
|
237
|
+
}, providers: [{ provide: MAT_OPTION_PARENT_COMPONENT, useExisting: MatAutocomplete }], animations: [panelAnimation], standalone: true, imports: [NgClass], template: "<ng-template let-formFieldId=\"id\">\n <div\n class=\"mat-mdc-autocomplete-panel mdc-menu-surface mdc-menu-surface--open\"\n role=\"listbox\"\n [id]=\"id\"\n [ngClass]=\"_classList\"\n [attr.aria-label]=\"ariaLabel || null\"\n [attr.aria-labelledby]=\"_getPanelAriaLabelledby(formFieldId)\"\n [@panelAnimation]=\"isOpen ? 'visible' : 'hidden'\"\n (@panelAnimation.done)=\"_animationDone.next($event)\"\n #panel>\n <ng-content></ng-content>\n </div>\n</ng-template>\n", styles: ["div.mat-mdc-autocomplete-panel{width:100%;max-height:256px;visibility:hidden;transform-origin:center top;overflow:auto;padding:8px 0;box-sizing:border-box;position:static;border-radius:var(--mat-autocomplete-container-shape);box-shadow:var(--mat-autocomplete-container-elevation-shadow);background-color:var(--mat-autocomplete-background-color)}.cdk-high-contrast-active div.mat-mdc-autocomplete-panel{outline:solid 1px}.cdk-overlay-pane:not(.mat-mdc-autocomplete-panel-above) div.mat-mdc-autocomplete-panel{border-top-left-radius:0;border-top-right-radius:0}.mat-mdc-autocomplete-panel-above div.mat-mdc-autocomplete-panel{border-bottom-left-radius:0;border-bottom-right-radius:0;transform-origin:center bottom}div.mat-mdc-autocomplete-panel.mat-mdc-autocomplete-visible{visibility:visible}div.mat-mdc-autocomplete-panel.mat-mdc-autocomplete-hidden{visibility:hidden;pointer-events:none}mat-autocomplete{display:none}"] }]
|
|
238
238
|
}], ctorParameters: () => [{ type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: undefined, decorators: [{
|
|
239
239
|
type: Inject,
|
|
240
240
|
args: [MAT_AUTOCOMPLETE_DEFAULT_OPTIONS]
|
|
@@ -472,13 +472,7 @@ class MatAutocompleteTrigger {
|
|
|
472
472
|
}
|
|
473
473
|
/** Opens the autocomplete suggestion panel. */
|
|
474
474
|
openPanel() {
|
|
475
|
-
this.
|
|
476
|
-
this._floatLabel();
|
|
477
|
-
// Add aria-owns attribute when the autocomplete becomes visible.
|
|
478
|
-
if (this._trackedModal) {
|
|
479
|
-
const panelId = this.autocomplete.id;
|
|
480
|
-
addAriaReferencedId(this._trackedModal, 'aria-owns', panelId);
|
|
481
|
-
}
|
|
475
|
+
this._openPanelInternal();
|
|
482
476
|
}
|
|
483
477
|
/** Closes the autocomplete suggestion panel. */
|
|
484
478
|
closePanel() {
|
|
@@ -593,6 +587,7 @@ class MatAutocompleteTrigger {
|
|
|
593
587
|
if (keyCode === ESCAPE && !hasModifier) {
|
|
594
588
|
event.preventDefault();
|
|
595
589
|
}
|
|
590
|
+
this._valueOnLastKeydown = this._element.nativeElement.value;
|
|
596
591
|
if (this.activeOption && keyCode === ENTER && this.panelOpen && !hasModifier) {
|
|
597
592
|
this.activeOption._selectViaInteraction();
|
|
598
593
|
this._resetActiveItem();
|
|
@@ -605,13 +600,13 @@ class MatAutocompleteTrigger {
|
|
|
605
600
|
this.autocomplete._keyManager.onKeydown(event);
|
|
606
601
|
}
|
|
607
602
|
else if (isArrowKey && this._canOpen()) {
|
|
608
|
-
this.
|
|
603
|
+
this._openPanelInternal(this._valueOnLastKeydown);
|
|
609
604
|
}
|
|
610
605
|
if (isArrowKey || this.autocomplete._keyManager.activeItem !== prevActiveItem) {
|
|
611
606
|
this._scrollToOption(this.autocomplete._keyManager.activeItemIndex || 0);
|
|
612
607
|
if (this.autocomplete.autoSelectActiveOption && this.activeOption) {
|
|
613
608
|
if (!this._pendingAutoselectedOption) {
|
|
614
|
-
this._valueBeforeAutoSelection = this.
|
|
609
|
+
this._valueBeforeAutoSelection = this._valueOnLastKeydown;
|
|
615
610
|
}
|
|
616
611
|
this._pendingAutoselectedOption = this.activeOption;
|
|
617
612
|
this._assignOptionValue(this.activeOption.value);
|
|
@@ -648,14 +643,21 @@ class MatAutocompleteTrigger {
|
|
|
648
643
|
// because the option will be reset when the panel is closed.
|
|
649
644
|
const selectedOption = this.autocomplete.options?.find(option => option.selected);
|
|
650
645
|
if (selectedOption) {
|
|
651
|
-
const display = this.
|
|
646
|
+
const display = this._getDisplayValue(selectedOption.value);
|
|
652
647
|
if (value !== display) {
|
|
653
648
|
selectedOption.deselect(false);
|
|
654
649
|
}
|
|
655
650
|
}
|
|
656
651
|
}
|
|
657
652
|
if (this._canOpen() && this._document.activeElement === event.target) {
|
|
658
|
-
|
|
653
|
+
// When the `input` event fires, the input's value will have already changed. This means
|
|
654
|
+
// that if we take the `this._element.nativeElement.value` directly, it'll be one keystroke
|
|
655
|
+
// behind. This can be a problem when the user selects a value, changes a character while
|
|
656
|
+
// the input still has focus and then clicks away (see #28432). To work around it, we
|
|
657
|
+
// capture the value in `keydown` so we can use it here.
|
|
658
|
+
const valueOnAttach = this._valueOnLastKeydown ?? this._element.nativeElement.value;
|
|
659
|
+
this._valueOnLastKeydown = null;
|
|
660
|
+
this._openPanelInternal(valueOnAttach);
|
|
659
661
|
}
|
|
660
662
|
}
|
|
661
663
|
}
|
|
@@ -665,13 +667,13 @@ class MatAutocompleteTrigger {
|
|
|
665
667
|
}
|
|
666
668
|
else if (this._canOpen()) {
|
|
667
669
|
this._previousValue = this._element.nativeElement.value;
|
|
668
|
-
this._attachOverlay();
|
|
670
|
+
this._attachOverlay(this._previousValue);
|
|
669
671
|
this._floatLabel(true);
|
|
670
672
|
}
|
|
671
673
|
}
|
|
672
674
|
_handleClick() {
|
|
673
675
|
if (this._canOpen() && !this.panelOpen) {
|
|
674
|
-
this.
|
|
676
|
+
this._openPanelInternal();
|
|
675
677
|
}
|
|
676
678
|
}
|
|
677
679
|
/**
|
|
@@ -765,10 +767,13 @@ class MatAutocompleteTrigger {
|
|
|
765
767
|
this._overlayRef = null;
|
|
766
768
|
}
|
|
767
769
|
}
|
|
770
|
+
/** Given a value, returns the string that should be shown within the input. */
|
|
771
|
+
_getDisplayValue(value) {
|
|
772
|
+
const autocomplete = this.autocomplete;
|
|
773
|
+
return autocomplete && autocomplete.displayWith ? autocomplete.displayWith(value) : value;
|
|
774
|
+
}
|
|
768
775
|
_assignOptionValue(value) {
|
|
769
|
-
const toDisplay = this.
|
|
770
|
-
? this.autocomplete.displayWith(value)
|
|
771
|
-
: value;
|
|
776
|
+
const toDisplay = this._getDisplayValue(value);
|
|
772
777
|
if (value == null) {
|
|
773
778
|
this._clearPreviousSelectedOption(null, false);
|
|
774
779
|
}
|
|
@@ -832,7 +837,16 @@ class MatAutocompleteTrigger {
|
|
|
832
837
|
}
|
|
833
838
|
});
|
|
834
839
|
}
|
|
835
|
-
|
|
840
|
+
_openPanelInternal(valueOnAttach = this._element.nativeElement.value) {
|
|
841
|
+
this._attachOverlay(valueOnAttach);
|
|
842
|
+
this._floatLabel();
|
|
843
|
+
// Add aria-owns attribute when the autocomplete becomes visible.
|
|
844
|
+
if (this._trackedModal) {
|
|
845
|
+
const panelId = this.autocomplete.id;
|
|
846
|
+
addAriaReferencedId(this._trackedModal, 'aria-owns', panelId);
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
_attachOverlay(valueOnAttach) {
|
|
836
850
|
if (!this.autocomplete && (typeof ngDevMode === 'undefined' || ngDevMode)) {
|
|
837
851
|
throw getMatAutocompleteMissingPanelError();
|
|
838
852
|
}
|
|
@@ -856,7 +870,8 @@ class MatAutocompleteTrigger {
|
|
|
856
870
|
}
|
|
857
871
|
if (overlayRef && !overlayRef.hasAttached()) {
|
|
858
872
|
overlayRef.attach(this._portal);
|
|
859
|
-
this._valueOnAttach =
|
|
873
|
+
this._valueOnAttach = valueOnAttach;
|
|
874
|
+
this._valueOnLastKeydown = null;
|
|
860
875
|
this._closingActionsSubscription = this._subscribeToClosingActions();
|
|
861
876
|
}
|
|
862
877
|
const wasOpen = this.panelOpen;
|