Skip to content

Commit

Permalink
Fix issue with element editor unload confirm dialogs. Bump to 1.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
mmikkel committed Aug 3, 2021
1 parent 4eee9b8 commit 0dc5c3f
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# ColorMate Changelog

## 1.0.4 - 2021-08-03
### Fixed
- Fixed issue where ColorMate could trigger unneccessary window unload confirm dialogs in element editor huds and slideouts

## 1.0.3 - 2020-08-20
### Fixed
- Fixed issue that could cause an exception when previewing a draft (fixes #3).
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vaersaagod/colormate",
"description": "Color me impressed, mate!",
"version": "1.0.3",
"version": "1.0.4",
"type": "craft-plugin",
"keywords": [
"craft",
Expand Down
6 changes: 0 additions & 6 deletions src/assetbundles/.browserslistrc

This file was deleted.

4 changes: 2 additions & 2 deletions src/assetbundles/dist/field.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/assetbundles/dist/field.js.map

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions src/assetbundles/src/components/ColorMateField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,19 @@
this.customOpacityInput = this.fieldValue.opacity;
}
}
// Prevent unwanted window unload confirm dialogs due to Craft serializing the initial DOM state before ColorMate boots up
requestAnimationFrame(() => {
var $editor = $(this.$el).closest('.element-editor,.hud');
if ($editor.length) {
this.elementEditor = $editor.data('elementEditor') || {};
if (this.elementEditor.slideout) {
this.elementEditor.initialData = this.elementEditor.slideout.$container.serialize();
} else if (this.elementEditor.hud) {
this.elementEditor.initialData = this.elementEditor.hud.$body.serialize();
}
}
});
}
}
</script>
Expand Down

0 comments on commit 0dc5c3f

Please sign in to comment.