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.

Unaccessible history state

See original GitHub issue

Do you want to request a feature or report a bug?

bug

What’s the current behavior?

https://jsfiddle.net/doodlewind/wo348Lc0/

  1. Using the <kbd>delete</kbd> button to delete some selected text.
  2. Focus on text, press cmd-z.

Previous state can’t be replayed with cmd-z since the editor is again blurred.

Behavior with cmd-z that loses focus:

bug-cmd-z

What’s the expected behavior?

cmd-z shouldn’t blur the editor. Expected Behavior with <kbd>undo</kbd> and <kbd>redo</kbd> button:

normal-undo-redo

Some investigations

This behaviour is regularly encountered in my editor project and it’s frustrating, since user will think their changes are ‘lost’. But in fact the history stack is preserved.

In Slate’s default examples, toolbar buttons doesn’t trigger this issue since changes are fired from onMouseDown and prevented default, editor is still focused afterwards. But when building advanced toolbar with color pickers or table pickers, mouse events can still blur the editor. In this case cmd-z is not usable.

IMHO it makes sense to always focus after redo or undo, the question is the place for the logic. Calling redo().focus() and undo().focus() as a workaround will break history stack and throw errors. Another workaround that calls delete().focus() is also awkward.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
doodlewindcommented, Oct 30, 2017

@chemzqm That’s exactly what #1330 implements.

1reaction
isubasticommented, Oct 30, 2017

@ianstormtaylor it seems that with the newest version of slate, the first operation is set_value which cause the error on undoing when history stack size is equal to 1. I got around this with hasUndo/hasRedo helpers that filters out stack that only have set_selection(focus/blur) or set_value(initialization) operation and handleRedo and handleUndo change function that check if it has undo/redo and run change.redo()/change.undo() till the change is not a set_selection operation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

branch - Unaccessible git state - Stack Overflow
1 Answer 1 ... Take a look at the output of git reflog . Look for the checkout, then do a git checkout...
Read more >
5.4 Session history and navigation — HTML5 - W3C
Each session history entry consists of either a URL or a state object, or both, and may in addition ... The actual entries...
Read more >
History.state - Web APIs - MDN Web Docs - Mozilla
The History.state property returns a value representing the state at the top of the history stack. This is a way to look at...
Read more >
Troubleshoot Firepower Threat Defense Policy Deployments
Pull up the Deployments list on the FMC Web UI. Step 2. While the Deployments tab is selected, click Show History . FMCHistory....
Read more >
Troubleshooting Amazon OpenSearch Service
Cluster in read-only state · If your cluster uses dedicated master nodes, quorum loss occurs when half or more are unavailable. If your...
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