Skip to content

Commit

Permalink
fix(interaction): problem with entering to Editor.js by Tab key (#1397)
Browse files Browse the repository at this point in the history
* Fix problem with entering to Editor.js by Tab key
* Optimize current block setting

Co-authored-by: t.hata <hata@impact-blue.co.jp>
  • Loading branch information
2 people authored and neSpecc committed Dec 8, 2020
1 parent 3c5c265 commit bbb4758
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dist/editor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

- `Fix` - The problem with destroy() method [#1380](https://github.com/codex-team/editor.js/issues/1380).
- `Fix` - add getter keyword to `block.mergeable` method [#1415](https://github.com/codex-team/editor.js/issues/1415).

- `Fix` — Fix problem with entering to Editor.js by Tab key [#1393](https://github.com/codex-team/editor.js/issues/1393)

### 2.19

Expand Down
9 changes: 8 additions & 1 deletion src/components/modules/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ export default class UI extends Module<UINodes> {
*/
private selectionChanged(event: Event): void {
const { CrossBlockSelection, BlockSelection } = this.Editor;
const focusedElement = Selection.anchorElement as Element;
const focusedElement = Selection.anchorElement;

if (CrossBlockSelection.isCrossBlockSelectionStarted) {
// Removes all ranges when any Block is selected
Expand All @@ -750,6 +750,13 @@ export default class UI extends Module<UINodes> {
return;
}

/**
* Set current block when entering to Editor.js by tab key
*/
if (!this.Editor.BlockManager.currentBlock) {
this.Editor.BlockManager.setCurrentBlockByChildNode(focusedElement);
}

/**
* @todo add debounce
*/
Expand Down

0 comments on commit bbb4758

Please sign in to comment.