Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop click propagation only if click cause action #1252

Merged
merged 3 commits into from
Sep 13, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/editor.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,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)
- `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)

### 2.18

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 @@ -647,8 +647,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 @@ -658,6 +660,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 @@ -667,6 +671,8 @@ export default class UI extends Module {
}

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

this.Editor.BlockManager.insert();
}

Expand All @@ -678,6 +684,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