Skip to content

Commit 77b0fbc

Browse files
authored
Revert "implement WPF TextInput blurOnSubmit (microsoft#1444)" (microsoft#1525)
Reverts microsoft#1444 This isn't implemented properly. There's a boolean at the root level of a view manager when view managers are responsible for many text inputs. By setting blurOnSubmit on one TextInput, you're effectively doing it for all of them with this PR.
1 parent e85d9f7 commit 77b0fbc

File tree

2 files changed

+4
-24
lines changed

2 files changed

+4
-24
lines changed

Libraries/Components/TextInput/TextInput.windows.js

-1
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,6 @@ var TextInput = createReactClass({
681681
selectionColor={this.props.selectionColor}
682682
text={this._getText()}
683683
editable={this.props.editable}
684-
blurOnSubmit={this.props.blurOnSubmit}
685684
/>;
686685
}
687686

ReactWindows/ReactNative.Net46/Views/TextInput/ReactTextInputManager.cs

+4-23
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ class ReactTextInputManager : BaseViewManager<ReactTextBox, ReactTextInputShadow
2121
internal const int BlurTextInput = 2;
2222

2323
private bool _onSelectionChange;
24-
private bool? _blurOnSubmit;
2524

2625
internal static readonly Color DefaultTextBoxBorder = Color.FromArgb(255, 122, 122, 122);
2726
internal static readonly Color DefaultPlaceholderTextColor = Color.FromArgb(255, 0, 0, 0);
@@ -332,10 +331,6 @@ public void SetMultiline(ReactTextBox view, bool multiline)
332331
{
333332
view.AcceptsReturn = multiline;
334333
view.TextWrapping = multiline ? TextWrapping.Wrap : TextWrapping.NoWrap;
335-
if (_blurOnSubmit == null)
336-
{
337-
_blurOnSubmit = !multiline;
338-
}
339334
}
340335

341336
/// <summary>
@@ -391,12 +386,6 @@ public void SetSelectTextOnFocus(ReactTextBox view, bool selectTextOnFocus)
391386
view.SelectTextOnFocus = selectTextOnFocus;
392387
}
393388

394-
[ReactProp("blurOnSubmit")]
395-
public void SetBlurOnSubmit(ReactTextBox view, bool blurOnSubmit)
396-
{
397-
_blurOnSubmit = blurOnSubmit;
398-
}
399-
400389
/// <summary>
401390
/// Create the shadow node instance.
402391
/// </summary>
@@ -488,7 +477,7 @@ public override void UpdateExtraData(ReactTextBox view, object extraData)
488477
public override void OnDropViewInstance(ThemedReactContext reactContext, ReactTextBox view)
489478
{
490479
base.OnDropViewInstance(reactContext, view);
491-
view.PreviewKeyDown -= OnKeyDown;
480+
view.KeyDown -= OnKeyDown;
492481
view.LostFocus -= OnLostFocus;
493482
view.GotFocus -= OnGotFocus;
494483
view.TextChanged -= OnTextChanged;
@@ -526,7 +515,7 @@ protected override void AddEventEmitters(ThemedReactContext reactContext, ReactT
526515
view.TextChanged += OnTextChanged;
527516
view.GotFocus += OnGotFocus;
528517
view.LostFocus += OnLostFocus;
529-
view.PreviewKeyDown += OnKeyDown;
518+
view.KeyDown += OnKeyDown;
530519
}
531520

532521
private void OnTextChanged(object sender, TextChangedEventArgs e)
@@ -572,20 +561,12 @@ private void OnLostFocus(object sender, RoutedEventArgs e)
572561

573562
private void OnKeyDown(object sender, KeyEventArgs e)
574563
{
575-
var shiftModifier = (Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift;
576-
var controlModifier = (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control;
577-
var blurOnSubmit = (_blurOnSubmit.HasValue && _blurOnSubmit.Value);
578-
579-
if (e.Key == Key.Enter && !shiftModifier)
564+
if (e.Key == Key.Enter)
580565
{
581566
var textBox = (ReactTextBox)sender;
582-
if (!textBox.AcceptsReturn || blurOnSubmit || controlModifier)
567+
if (!textBox.AcceptsReturn)
583568
{
584569
e.Handled = true;
585-
if (blurOnSubmit)
586-
{
587-
Keyboard.ClearFocus();
588-
}
589570
textBox.GetReactContext()
590571
.GetNativeModule<UIManagerModule>()
591572
.EventDispatcher

0 commit comments

Comments
 (0)