Does not focus block when using insert()
See original GitHub issueHi there, thanks so much for your work on this!
I’m using insert()
to add a new block when a user clicks a button:
insert(blockType) {
// need to be explicit with index, otherwise editor.js adds block at the beginning...
const index = editor.blocks.getBlocksCount() + 1
editor.blocks.insert(blockType, {}, {}, index, true)
}
<ul>
<li @click="insert('header')">Title</li>
<li @click="insert('paragraph')">Text</li>
</ul>
Even though I set the last param (needToFocus
) to true
, it doesn’t focus the newly inserted block.
Of course, you can use the Caret API to focus the last inserted block like so:
editor.caret.setToLastBlock('start', 0)
… but then what is the needToFocus
param for in the insert()
method? 😃
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Focusing: focus/blur - The Modern JavaScript Tutorial
The method elem.focus() doesn't work on them, and focus/blur events are never triggered. This can be changed using HTML-attribute tabindex .
Read more >In React ES6, why does the input field lose focus after typing a ...
I was using a key from a text field. Inside the same block; I had an input field to update the value of...
Read more >Control focus with tabindex - web.dev
Insert an element into the tab order # To focus an element, press the Tab key or call the element's focus() method. This...
Read more >Deep dive - Summernote
Super Simple WYSIWYG Editor on Bootstrap Summernote is a JavaScript library that helps you ... You can compose a toolbar with pre-shipped buttons....
Read more >after - CSS: Cascading Style Sheets - MDN Web Docs - Mozilla
It is often used to add cosmetic content to an element with the ... 0 to make each span keyboard focusable, and using...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We’ve found some misunderstanding in usage of
needToFocus
param. Actually, it does not set a caret for now but changes thefocused
(highlighted) state of the block.We will change its behaviour in the next versions.
BUMP -> What’s the status of this? I’m running into this issue as well.