Skip to content

Commit

Permalink
Prevent errors with layerable textnodes. Fixes #5720
Browse files Browse the repository at this point in the history
  • Loading branch information
artf committed Mar 7, 2024
1 parent 209eeec commit 78a5f19
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/navigator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ export default class LayerManager extends Module<LayerManagerConfig> {
__isLayerable(cmp: Component): boolean {
const tag = cmp.get('tagName');
const hideText = this.config.hideTextnode;
const isValid = !hideText || (!cmp.is('textnode') && tag !== 'br');
const isValid = !hideText || (!cmp.isInstanceOf('textnode') && tag !== 'br');

return isValid && cmp.get('layerable')!;
}
Expand Down
7 changes: 3 additions & 4 deletions src/navigator/view/ItemView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import Component from '../../dom_components/model/Component';
import ComponentView from '../../dom_components/view/ComponentView';
import EditorModel from '../../editor/model/Editor';
import { isEnterKey, isEscKey } from '../../utils/dom';
import { getModel } from '../../utils/mixins';
import LayerManager from '../index';
import ItemsView from './ItemsView';
import { getOnComponentDrag, getOnComponentDragEnd, getOnComponentDragStart } from '../../commands';
Expand Down Expand Up @@ -96,8 +95,8 @@ export default class ItemView extends View {
return this.config.stylePrefix;
}

opt: any;
module: any;
opt: ItemViewProps;
module: LayerManager;
config: any;
sorter: any;
/** @ts-ignore */
Expand Down Expand Up @@ -357,7 +356,7 @@ export default class ItemView extends View {
const countEl = itemEl.find('[data-count]');

title[count ? 'removeClass' : 'addClass'](clsNoChild);
countEl.html(count || '');
countEl.html(`${count || ''}`);
!count && module.setOpen(model, false);
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const attrUp = (el?: HTMLElement, attrs: ObjectAny = {}) =>
el && el.setAttribute && each(attrs, (value, key) => el.setAttribute(key, value));

export const isVisible = (el?: HTMLElement) => {
return el && !!(el.offsetWidth || el.offsetHeight || el.getClientRects().length);
return el && !!(el.offsetWidth || el.offsetHeight || el.getClientRects?.().length);
};

export const empty = (node: HTMLElement) => {
Expand Down

0 comments on commit 78a5f19

Please sign in to comment.