Skip to content

Commit 2b06bf8

Browse files
authored
Merge pull request #556 from Harbour-Enterprises/artem-HAR-9815
2 parents da53559 + 9c4fbe3 commit 2b06bf8

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

packages/super-editor/src/components/toolbar/super-toolbar.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)