@@ -186,12 +186,7 @@ export class SuperToolbar extends EventEmitter {
186186 this . config . selector = this . config . element ;
187187 }
188188
189- this . toolbarContainer = this . getElementBySelector ( this . config . selector ) ;
190-
191- if ( ! this . toolbarContainer ) {
192- return ;
193- }
194-
189+ this . toolbarContainer = this . findElementBySelector ( this . config . selector ) ;
195190 this . #initToolbarGroups( ) ;
196191 this . #makeToolbarItems( {
197192 superToolbar : this ,
@@ -202,6 +197,10 @@ export class SuperToolbar extends EventEmitter {
202197 isDev : config . isDev ,
203198 } ) ;
204199
200+ if ( this . config . selector && ! this . toolbarContainer ) {
201+ return ;
202+ }
203+
205204 this . app = createApp ( Toolbar ) ;
206205 this . app . directive ( 'click-outside' , vClickOutside ) ;
207206 this . app . config . globalProperties . $toolbar = this ;
@@ -212,7 +211,7 @@ export class SuperToolbar extends EventEmitter {
212211 this . updateToolbarState ( ) ;
213212 }
214213
215- getElementBySelector ( selector ) {
214+ findElementBySelector ( selector ) {
216215 let el = null ;
217216
218217 if ( selector ) {
@@ -607,7 +606,7 @@ export class SuperToolbar extends EventEmitter {
607606 isDev = false ,
608607 } = { } ) {
609608 const documentWidth = document . documentElement . clientWidth ; // take into account the scrollbar
610- const containerWidth = this . toolbarContainer . offsetWidth ;
609+ const containerWidth = this . toolbarContainer ? .offsetWidth ?? 0 ;
611610 const availableWidth = this . config . responsiveToContainer ? containerWidth : documentWidth ;
612611
613612 const { defaultItems, overflowItems } = makeDefaultItems ( {
0 commit comments