Skip to content

Commit

Permalink
Stop click propagation only if click cause action (#1252)
Browse files Browse the repository at this point in the history
  • Loading branch information
gohabereg authored Sep 13, 2020
1 parent 274e1d1 commit c1f9dd6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dist/editor.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
- `Improvements` - The `initialBlock` property of Editor config is deprecated. Use the `defaultBlock` instead. [#993](https://github.com/codex-team/editor.js/issues/993)
- `Fix` - Fixed the issue of toolbar not disappearing on entering input in Chinese, Hindi and some other languages. [#1196](https://github.com/codex-team/editor.js/issues/1196)
- `Improvements` - BlockAPI `call()` method now returns the result of calling method, thus allowing it to expose arbitrary data as needed [#1205](https://github.com/codex-team/editor.js/pull/1205)
- `Improvements` - Unuseful log about missed i18n section has been removed [#1269](https://github.com/codex-team/editor.js/issues/1269)
- `Fix` - Do not stop events propagation if not needed (essential for React synthetic events) [#1051](https://github.com/codex-team/editor.js/issues/1051) [#946](https://github.com/codex-team/editor.js/issues/946)
- `Fix` - Tool's `destroy` method is not invoked when `editor.destroy()` is called. [#1047](https://github.com/codex-team/editor.js/issues/1047)
- `New` - Tool's `reset` static method added to the API to clean up any data added by Tool on initialization
- `Improvements` - Unuseful log about missed i18n section has been removed [#1269](https://github.com/codex-team/editor.js/issues/1269)
Expand Down
12 changes: 10 additions & 2 deletions src/components/modules/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -651,8 +651,10 @@ export default class UI extends Module {
return;
}

event.stopImmediatePropagation();
event.stopPropagation();
const stopPropagation = (): void => {
event.stopImmediatePropagation();
event.stopPropagation();
};

/**
* case when user clicks on anchor element
Expand All @@ -662,6 +664,8 @@ export default class UI extends Module {
const ctrlKey = event.metaKey || event.ctrlKey;

if ($.isAnchor(element) && ctrlKey) {
stopPropagation();

const href = element.getAttribute('href');
const validUrl = _.getValidUrl(href);

Expand All @@ -671,6 +675,8 @@ export default class UI extends Module {
}

if (!this.Editor.BlockManager.currentBlock) {
stopPropagation();

this.Editor.BlockManager.insert();
}

Expand All @@ -682,6 +688,8 @@ export default class UI extends Module {
const isDefaultBlock = this.Editor.Tools.isDefault(this.Editor.BlockManager.currentBlock.tool);

if (isDefaultBlock) {
stopPropagation();

/**
* Check isEmpty only for paragraphs to prevent unnecessary tree-walking on Tools with many nodes (for ex. Table)
*/
Expand Down

0 comments on commit c1f9dd6

Please sign in to comment.