@@ -71,15 +71,15 @@ export const DESCRIPTION_ID = 'option-picker';
7171export class PickerBase extends SizedMixin ( Focusable , { noDefaultSize : true } ) {
7272 public isMobile = new MatchMediaController ( this , IS_MOBILE ) ;
7373
74- public strategy ? : DesktopController | MobileController ;
74+ public strategy ! : DesktopController | MobileController ;
7575
7676 @state ( )
7777 appliedLabel ?: string ;
7878
7979 @query ( '#button' )
8080 public button ! : HTMLButtonElement ;
8181
82- private dependencyManager = new DependencyManagerController ( this ) ;
82+ public dependencyManager = new DependencyManagerController ( this ) ;
8383
8484 private deprecatedMenu : Menu | null = null ;
8585
@@ -217,6 +217,7 @@ export class PickerBase extends SizedMixin(Focusable, { noDefaultSize: true }) {
217217 } else {
218218 // Non-cancelable "change" events announce a selection with no value
219219 // change that should close the Picker element.
220+ this . open = false ;
220221 if ( this . strategy ) {
221222 this . strategy . open = false ;
222223 }
@@ -249,6 +250,7 @@ export class PickerBase extends SizedMixin(Focusable, { noDefaultSize: true }) {
249250 item : MenuItem ,
250251 menuChangeEvent ?: Event
251252 ) : Promise < void > {
253+ this . open = false ;
252254 // should always close when "setting" a value
253255 if ( this . strategy ) {
254256 this . strategy . open = false ;
@@ -278,6 +280,7 @@ export class PickerBase extends SizedMixin(Focusable, { noDefaultSize: true }) {
278280 }
279281 this . selectedItem = oldSelectedItem ;
280282 this . value = oldValue ;
283+ this . open = true ;
281284 if ( this . strategy ) {
282285 this . strategy . open = true ;
283286 }
@@ -304,9 +307,9 @@ export class PickerBase extends SizedMixin(Focusable, { noDefaultSize: true }) {
304307 if ( this . readonly || this . pending ) {
305308 return ;
306309 }
310+ this . open = typeof target !== 'undefined' ? target : ! this . open ;
307311 if ( this . strategy ) {
308- this . strategy . open =
309- typeof target !== 'undefined' ? target : ! this . open ;
312+ this . strategy . open = this . open ;
310313 }
311314 }
312315
@@ -315,6 +318,7 @@ export class PickerBase extends SizedMixin(Focusable, { noDefaultSize: true }) {
315318 return ;
316319 }
317320 if ( this . strategy ) {
321+ this . open = false ;
318322 this . strategy . open = false ;
319323 }
320324 }
@@ -456,6 +460,9 @@ export class PickerBase extends SizedMixin(Focusable, { noDefaultSize: true }) {
456460 } ;
457461
458462 protected renderOverlay ( menu : TemplateResult ) : TemplateResult {
463+ if ( this . strategy ?. overlay === undefined ) {
464+ return menu ;
465+ }
459466 const container = this . renderContainer ( menu ) ;
460467 render ( container , this . strategy ?. overlay as unknown as HTMLElement , {
461468 host : this ,
@@ -517,11 +524,13 @@ export class PickerBase extends SizedMixin(Focusable, { noDefaultSize: true }) {
517524 }
518525 if ( changes . has ( 'disabled' ) && this . disabled ) {
519526 if ( this . strategy ) {
527+ this . open = false ;
520528 this . strategy . open = false ;
521529 }
522530 }
523531 if ( changes . has ( 'pending' ) && this . pending ) {
524532 if ( this . strategy ) {
533+ this . open = false ;
525534 this . strategy . open = false ;
526535 }
527536 }
@@ -580,6 +589,13 @@ export class PickerBase extends SizedMixin(Focusable, { noDefaultSize: true }) {
580589 this . button . addEventListener ( 'keydown' , this . handleKeydown ) ;
581590 }
582591
592+ protected override updated ( changes : PropertyValues < this> ) : void {
593+ super . updated ( changes ) ;
594+ if ( changes . has ( 'open' ) ) {
595+ this . strategy . open = this . open ;
596+ }
597+ }
598+
583599 protected override firstUpdated ( changes : PropertyValues < this> ) : void {
584600 super . firstUpdated ( changes ) ;
585601 this . bindButtonKeydownListener ( ) ;
@@ -658,6 +674,9 @@ export class PickerBase extends SizedMixin(Focusable, { noDefaultSize: true }) {
658674 this . open ||
659675 ! ! this . deprecatedMenu ;
660676 if ( this . hasRenderedOverlay ) {
677+ if ( this . dependencyManager . loaded ) {
678+ this . dependencyManager . add ( 'sp-overlay' ) ;
679+ }
661680 return this . renderOverlay ( menu ) ;
662681 }
663682 return menu ;
@@ -765,7 +784,6 @@ export class PickerBase extends SizedMixin(Focusable, { noDefaultSize: true }) {
765784
766785 protected bindEvents ( ) : void {
767786 this . strategy ?. abort ( ) ;
768- this . strategy = undefined ;
769787 if ( this . isMobile . matches ) {
770788 this . strategy = new strategies [ 'mobile' ] ( this . button , this ) ;
771789 } else {
0 commit comments