codex-team / codex-team/editor.js
[Bug] Cannot read property 'inputs' of undefined on CMD+A
- Dominant language
- TypeScript
- Stars
- 31.9k
- Forks
- 2.2k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 1
Description
Describe a bug.
CMD+A when focused in editor area but not on a block throws error `Cannot read property 'inputs' of undefined`
This code is actually supposed to handle this case but when we initialise the editor, for some reason all the block one by one gets set as the currentBlock. At the end of the loop the last block gets set as the currentBlock.
https://github.com/codex-team/editor.js/blob/43032ebaac6a8b9a67c9bf2ada5adc0f8592d546/src/components/modules/blockSelection.ts#L178
Crashes here
https://github.com/codex-team/editor.js/blob/43032ebaac6a8b9a67c9bf2ada5adc0f8592d546/src/components/modules/blockSelection.ts#L387
event.target is not a block so workingBlock comes undefined.
I've put a temporary fix for myself as `const inputs = workingBlock?.inputs || [];`. If you think that is a correct fix and not fixing the setting of currentBlock on editor initialise, I can open a pull request for it.
Steps to reproduce:
1. Go to https://editorjs.io/
2. Click within the editor area such that block tunes show up but doesn't focus any block.
3. Press CMD+A and check console.
Expected behavior:
Just select all blocks or ignore if editor not in focus
Screenshots:

Device, Browser, OS:
Macbook Pro, Chrome, MacOS
Editor.js version:
2.19 but happens in 2.18 too
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.