mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
fix(select): scroll strategy token cannot inject overlay (#10535)
This commit is contained in:
committed by
Andrew Seguin
parent
c05005a688
commit
3eb71c2432
@@ -5,12 +5,13 @@
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
import {NgModule} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {MatSelect, MatSelectTrigger} from './select';
|
||||
import {MatCommonModule, MatOptionModule} from '@angular/material/core';
|
||||
|
||||
import {OverlayModule} from '@angular/cdk/overlay';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {NgModule} from '@angular/core';
|
||||
import {MatCommonModule, MatOptionModule} from '@angular/material/core';
|
||||
import {MatFormFieldModule} from '@angular/material/form-field';
|
||||
import {MAT_SELECT_SCROLL_STRATEGY_PROVIDER, MatSelect, MatSelectTrigger} from './select';
|
||||
|
||||
|
||||
@NgModule({
|
||||
@@ -22,5 +23,6 @@ import {MatFormFieldModule} from '@angular/material/form-field';
|
||||
],
|
||||
exports: [MatFormFieldModule, MatSelect, MatSelectTrigger, MatOptionModule, MatCommonModule],
|
||||
declarations: [MatSelect, MatSelectTrigger],
|
||||
providers: [MAT_SELECT_SCROLL_STRATEGY_PROVIDER]
|
||||
})
|
||||
export class MatSelectModule {}
|
||||
|
||||
+17
-10
@@ -23,10 +23,10 @@ import {
|
||||
import {
|
||||
CdkConnectedOverlay,
|
||||
Overlay,
|
||||
RepositionScrollStrategy,
|
||||
ScrollStrategy,
|
||||
ViewportRuler,
|
||||
} from '@angular/cdk/overlay';
|
||||
import {filter, take, map, switchMap, takeUntil, startWith} from 'rxjs/operators';
|
||||
import {
|
||||
AfterContentInit,
|
||||
Attribute,
|
||||
@@ -40,7 +40,6 @@ import {
|
||||
ElementRef,
|
||||
EventEmitter,
|
||||
Inject,
|
||||
inject,
|
||||
InjectionToken,
|
||||
Input,
|
||||
isDevMode,
|
||||
@@ -75,7 +74,8 @@ import {
|
||||
mixinTabIndex,
|
||||
} from '@angular/material/core';
|
||||
import {MatFormField, MatFormFieldControl} from '@angular/material/form-field';
|
||||
import {defer, Subject, merge, Observable} from 'rxjs';
|
||||
import {defer, merge, Observable, Subject} from 'rxjs';
|
||||
import {filter, map, startWith, switchMap, take, takeUntil} from 'rxjs/operators';
|
||||
import {matSelectAnimations} from './select-animations';
|
||||
import {
|
||||
getMatSelectDynamicMultipleError,
|
||||
@@ -122,13 +122,20 @@ export const SELECT_PANEL_VIEWPORT_PADDING = 8;
|
||||
|
||||
/** Injection token that determines the scroll handling while a select is open. */
|
||||
export const MAT_SELECT_SCROLL_STRATEGY =
|
||||
new InjectionToken<() => ScrollStrategy>('mat-select-scroll-strategy', {
|
||||
providedIn: 'root',
|
||||
factory: () => {
|
||||
const overlay = inject(Overlay);
|
||||
return () => overlay.scrollStrategies.reposition();
|
||||
}
|
||||
});
|
||||
new InjectionToken<() => ScrollStrategy>('mat-select-scroll-strategy');
|
||||
|
||||
/** @docs-private */
|
||||
export function MAT_SELECT_SCROLL_STRATEGY_PROVIDER_FACTORY(overlay: Overlay):
|
||||
() => RepositionScrollStrategy {
|
||||
return () => overlay.scrollStrategies.reposition();
|
||||
}
|
||||
|
||||
/** @docs-private */
|
||||
export const MAT_SELECT_SCROLL_STRATEGY_PROVIDER = {
|
||||
provide: MAT_SELECT_SCROLL_STRATEGY,
|
||||
deps: [Overlay],
|
||||
useFactory: MAT_SELECT_SCROLL_STRATEGY_PROVIDER_FACTORY,
|
||||
};
|
||||
|
||||
/** Change event object that is emitted when the select value has changed. */
|
||||
export class MatSelectChange {
|
||||
|
||||
Reference in New Issue
Block a user