@@ -12,12 +12,12 @@ import {
1212 ElementRef ,
1313 NgZone ,
1414 QueryList ,
15+ signal ,
1516 SimpleChanges ,
1617 ViewChild ,
17- ViewChildren ,
18- signal
18+ ViewChildren
1919} from '@angular/core' ;
20- import { ComponentFixture , inject as testingInject , TestBed } from '@angular/core/testing' ;
20+ import { ComponentFixture , TestBed , inject as testingInject } from '@angular/core/testing' ;
2121import { FormControl , FormsModule , ReactiveFormsModule } from '@angular/forms' ;
2222import { By } from '@angular/platform-browser' ;
2323import { Subject } from 'rxjs' ;
@@ -302,6 +302,27 @@ describe('auto-complete', () => {
302302 expect ( Math . ceil ( parseFloat ( overlayPane . style . width ) ) ) . toBe ( 500 ) ;
303303 } ) ;
304304
305+ it ( 'should apply dropdown match select width' , ( ) => {
306+ component . dropdownMatchSelectWidth . set ( true ) ;
307+ component . width . set ( 500 ) ;
308+ fixture . detectChanges ( ) ;
309+
310+ component . trigger . openPanel ( ) ;
311+ fixture . detectChanges ( ) ;
312+
313+ const overlayPane = overlayContainerElement . querySelector ( '.cdk-overlay-pane' ) as HTMLElement ;
314+ expect ( Math . ceil ( parseFloat ( overlayPane . style . width ) ) ) . toBe ( 500 ) ;
315+
316+ component . dropdownMatchSelectWidth . set ( false ) ;
317+ component . trigger . closePanel ( ) ;
318+ fixture . detectChanges ( ) ;
319+
320+ component . trigger . openPanel ( ) ;
321+ fixture . detectChanges ( ) ;
322+
323+ expect ( Math . ceil ( parseFloat ( overlayPane . style . width ) ) ) . not . toBe ( 500 ) ;
324+ } ) ;
325+
305326 it ( 'should backfill display value when DOWN key is pressed' , async ( ) => {
306327 component . trigger . openPanel ( ) ;
307328 await stabilize ( fixture , 0 ) ;
@@ -900,6 +921,7 @@ class NzTestSimpleAutocompleteComponent {
900921 [nzOverlayClassName]="overlayClassName()"
901922 [nzOverlayStyle]="overlayStyle()"
902923 [nzDataSource]="options()"
924+ [nzDropdownMatchSelectWidth]="dropdownMatchSelectWidth()"
903925 [nzDefaultActiveFirstOption]="false"
904926 nzBackfill
905927 #auto
@@ -909,6 +931,7 @@ class NzTestSimpleAutocompleteComponent {
909931class NzTestAutocompletePropertyComponent {
910932 inputValue ?: string ;
911933 readonly width = signal < number | undefined > ( undefined ) ;
934+ readonly dropdownMatchSelectWidth = signal ( true ) ;
912935 readonly overlayClassName = signal ( '' ) ;
913936 readonly overlayStyle = signal ( { } ) ;
914937 readonly options = signal ( [ 'Burns Bay Road' , 'Downing Street' , 'Wall Street' ] ) ;
0 commit comments