0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

Fixed error when creating a block-editable card in the editor

no issue

The toolbar display/positioning logic was recently changed so that the toolbar is shown when a `saveAsSnippet` action is passed in. However the `_setToolbarProperties` method wasn't taking into account the toolbar element not being present when in editing mode such as when a block-editable card (markdown, html, code) is created.

- remove conditional logic that may change over time and replace it with checks for the toolbar element existing
This commit is contained in:
Kevin Ansfield 2020-11-06 18:13:32 +00:00
parent 4f86f3ddeb
commit 81ec6729c8

View file

@ -249,17 +249,20 @@ export default Component.extend({
},
_setToolbarProperties() {
if (this.toolbar || this.saveAsSnippet) {
// select the last toolbar in the element because card contents/captions
// may have their own toolbar elements
let toolbar = this.element.querySelector(':scope > [data-kg-toolbar="true"]');
let {width, height} = toolbar.getBoundingClientRect();
// select the last toolbar in the element because card contents/captions
// may have their own toolbar elements
let toolbar = this.element?.querySelector(':scope > [data-kg-toolbar="true"]');
this.setProperties({
toolbarWidth: width,
toolbarHeight: height + TICK_HEIGHT
});
if (!toolbar) {
return;
}
let {width, height} = toolbar.getBoundingClientRect();
this.setProperties({
toolbarWidth: width,
toolbarHeight: height + TICK_HEIGHT
});
},
_showToolbar() {