question-mark
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.

Is there a better way to handle void nodes?

See original GitHub issue

Hi Ian,

I had a thought I’d like to share and forgive me if I’m misunderstanding the issue.

I’m just putting this out there as I think there may be an inherent mismatch between the way we expect void nodes to work and how they are represented internally. I believe this may be creating edge cases and increasing code complexity.

The following issue made me write this post but I believe I’ve seen similar issues surrounding void blocks:

https://github.com/ianstormtaylor/slate/issues/660

From my understanding, void nodes are represented as a block node that contains a single character (with void set to true).

When the selection is within the void block, our expected behavior is that the void block is selected (even though in reality the character isn’t selected). For example, if the void block was an image, the UI would show the image is selected and if I hit backspace or delete the void block would be deleted.

This is inherently different than the behavior of a single character where upon entering the void block, the cursor is typically either before or after that single character. What happens on backspace or delete would depend on whether the cursor was before or after the character. It would only be after we SHIFT-LEFT or SHIFT-RIGHT to select the character that we would see this behavior.

I do understand that Slate handles this behavior correctly but I think it’s handling this as a special edge case around void blocks. If not, my post may be moot. 😃

It feels like it would be more consistent that as soon as we enter a void node, the entire character is immediately selected. Then, backspace and delete would work correctly as would (I presume) cut and paste with void blocks.

There would need to be special handling around SHIFT-RIGHT/LEFT/UP/DOWN and mouse selection because the actual anchor may be before or after the single character otherwise extending it in the wrong direction may unselect the anchor void block. However, I feel like this puts the special handling in the right place.

Another option is to remove the character since, well, void blocks are special so why not just be explicit around it’s difference in the code.

Either way, I do feel like there is a lack of documentation around void blocks. They are so integral to SlateJS but they seem to have little documentation around them. I’d be happy to spend some time documenting them but I wouldn’t mind having a short talk (perhaps by Skype or on Slack voice or other) to make sure I’m understanding what’s going on without dissecting the source code in its entirety.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
tobiastheilcommented, May 25, 2017

@bunterWolf Could you please share your code for the single space character? That would be so great!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do you use void pointers to create a more general node ...
For this my teacher recommended using a void pointer type to store the data for each node. Don't use void* unless you really...
Read more >
Void - WARFRAME Wiki - Fandom
Note that the Void missions accessible from Sedna junction are considered to be "Tier 4" (T4) difficulty. Enemies will deal +200% bonus damage...
Read more >
Effects of void nodes on epidemic spreads in networks - Nature
Thus, introducing the void nodes in the network leads to more heterogeneous network and reduces the final epidemic size.
Read more >
void operator - JavaScript - MDN Web Docs
The void operator evaluates the given expression and then returns undefined.
Read more >
Node — Godot Engine (stable) documentation in English
Note: This method is only called if the node is present in the scene tree (i.e. if it's not an orphan). void _physics_process...
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found