Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Does not focus block when using insert()

See original GitHub issue

Hi 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)
  <li @click="insert('header')">Title</li>
  <li @click="insert('paragraph')">Text</li>

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:open
  • Created 4 years ago
  • Reactions:2
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

neSpecccommented, Jun 30, 2020

We’ve found some misunderstanding in usage of needToFocus param. Actually, it does not set a caret for now but changes the focused (highlighted) state of the block.

We will change its behaviour in the next versions.

ryandunnewoldcommented, Apr 24, 2020

BUMP -> What’s the status of this? I’m running into this issue as well.

Read more comments on GitHub >

github_iconTop 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 -
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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found