Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add undo/redo support for TextInput #1274

Merged

Conversation

christophpurrer
Copy link

Please select one of the following

  • I am removing an existing difference between facebook/react-native and microsoft/react-native-macos 👍
  • I am cherry-picking a change from Facebook's react-native into microsoft/react-native-macos 👍
  • I am making a fix / change for the macOS implementation of react-native
  • I am making a change required for Microsoft usage of react-native

Setting allowsUndo = YES and having the NSTextView delegate return a stable NSUndoManager mostly makes undo/redo work, but we also need to register an undo action whenever the input contents was changed to something unexpected by JS.

This also breaks undo coalescing in a couple key places to make the input behave naturally like other apps.

Changelog

[macOS] [Added] - Add undo/redo support for TextInput

Test Plan

Before

Note: Bottom left corner casts key strokes from my keyboard

before.mov

After

after.mov

Setting `allowsUndo = YES` and having the `NSTextView` delegate return a stable `NSUndoManager` mostly makes undo/redo work, but we also needed to register an undo action whenever the input contents was changed to something unexpected by JS.

This also breaks undo coalescing in a couple key places to make the input behave naturally like other apps.
@christophpurrer christophpurrer requested a review from a team as a code owner July 22, 2022 15:09
@harrieshin harrieshin merged commit b1e6b97 into microsoft:main Jul 22, 2022
shwanton pushed a commit to shwanton/react-native-macos that referenced this pull request Feb 13, 2023
Setting `allowsUndo = YES` and having the `NSTextView` delegate return a stable `NSUndoManager` mostly makes undo/redo work, but we also needed to register an undo action whenever the input contents was changed to something unexpected by JS.

This also breaks undo coalescing in a couple key places to make the input behave naturally like other apps.

Co-authored-by: Scott Kyle <skyle@fb.com>
# Conflicts:
#	Libraries/Text/TextInput/Multiline/RCTUITextView.m
shwanton pushed a commit to shwanton/react-native-macos that referenced this pull request Mar 10, 2023
Setting `allowsUndo = YES` and having the `NSTextView` delegate return a stable `NSUndoManager` mostly makes undo/redo work, but we also needed to register an undo action whenever the input contents was changed to something unexpected by JS.

This also breaks undo coalescing in a couple key places to make the input behave naturally like other apps.

Co-authored-by: Scott Kyle <skyle@fb.com>
# Conflicts:
#	Libraries/Text/TextInput/Multiline/RCTUITextView.m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants