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.

There is no way to disable undo

See original GitHub issue

Do you want to request a feature or report a bug? Documentation error and missing function.

What is the current behavior? The documentation says you should not modify the allowUndo property directly, but instead use the provided static and instance functions. There is not an instance function which allows you to set allowUndo.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://jsfiddle.net or similar. The source code says that the _immutable property of the editor state is private and should not be modified, but since there is no other way to do this, thankfully the editor state is just an instance property and can be modified and set.

editorState._immutable = editorState._immutable.set('allowUndo', false);

This is currently the only way to set allowUndo and it’s no bueno. Overwriting a private instance property from outside like this is an anti-pattern.

What is the expected behavior? There should be an instance function to change allowUndo.

Which versions of Draft.js, and which browser / OS are affected by this issue? Did this work in previous versions of Draft.js? All of them.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:16 (3 by maintainers)

github_iconTop GitHub Comments

12reactions
gbbrcommented, Aug 22, 2017

Update on this, to accomplish this behaviour, one needs to do the following:

editorState = EditorState.set(editorState, {allowUndo: false});
// make changes
editorState = EditorState.set(editorState, {allowUndo: true});

This solution works!

3reactions
Pelsincommented, Aug 30, 2016

You seem to mutate the already created “editorState”. Instead, return a new “editorState” using the “EditorState” static setter with the new config. As the immutable pattern is intended ;P

Like this

const editorState = EditorState.set(oldEditorState, { allowUndo: false });

You can also do it when creating the editorState using the static method: https://facebook.github.io/draft-js/docs/api-reference-editor-state.html#create

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why Does My iPhone Keep Popping Up With Nothing to Undo ...
An alternative way to disable the Shake to Undo feature is to downgrade your Apple firmware to a pre-iOS 3.0 version. Downgrading the...
Read more >
Disable Shake to Undo - Apple Community
The only thing you can do is to try not to shake your phone while you are typing.
Read more >
How to Disable Shake To Undo on iPhone, iPad, & iPod Touch
With the feature off, no more undo dialog appears, including the “nothing to undo” message if it is accidentally activated. And with the...
Read more >
How to Turn Off Shake to Undo on iPhone & iPad - YouTube
How to Turn Off Shake to Undo on iPhone & iPad? In this tutorial, I show you how to disable Shake to Undo...
Read more >
How to Turn OFF/Disable Shake to Undo in iOS 15 on iPhone ...
Shake to undo is rather annoying. Here is how to turn off / disable Shake to Undo in iOS 15 on iPhone.#iOS15, #iPhone,...
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