@@ -212,7 +212,7 @@ class TextEditingElement {
212
212
///
213
213
/// In IOS, the virtual keyboard shifts the screen up if the focused input
214
214
/// element is under the keyboard or very close to the keyboard. Before the
215
- /// focus is called we are positining it offscreen. The location of the input
215
+ /// focus is called we are positioning it offscreen. The location of the input
216
216
/// in IOS is set to correct place, 100ms after focus. We use this timer for
217
217
/// timing this delay.
218
218
Timer _positionInputElementTimer;
@@ -292,8 +292,7 @@ class TextEditingElement {
292
292
}));
293
293
}
294
294
295
- if (browserEngine == BrowserEngine .webkit &&
296
- operatingSystem == OperatingSystem .iOs) {
295
+ if (owner.doesKeyboardShiftInput) {
297
296
/// Position the element outside of the page before focusing on it.
298
297
///
299
298
/// See [_positionInputElementTimer] .
@@ -625,16 +624,15 @@ class HybridTextEditing {
625
624
/// Also used to define if a keyboard is needed.
626
625
bool _isEditing = false ;
627
626
628
- /// Flag indication the input element needs to be positioned.
627
+ /// Flag indicating the input element needs to be positioned.
629
628
///
630
629
/// See [TextEditingElement._delayBeforePositining] .
631
630
bool get inputElementNeedsToBePositioned =>
632
631
! inputPositioned &&
633
632
_isEditing &&
634
- browserEngine == BrowserEngine .webkit &&
635
- operatingSystem == OperatingSystem .iOs;
633
+ doesKeyboardShiftInput;
636
634
637
- /// Flag indication wheterher the input element's position is set.
635
+ /// Flag indicating whether the input element's position is set.
638
636
///
639
637
/// See [inputElementNeedsToBePositioned] .
640
638
bool inputPositioned = false ;
@@ -763,21 +761,30 @@ class HybridTextEditing {
763
761
);
764
762
}
765
763
764
+ /// Positioning of input element is only done if we are not expecting input
765
+ /// to be shifted by a virtual keyboard or if the input is already positioned.
766
+ ///
767
+ /// Otherwise positioning will be done after focusing on the input.
768
+ /// See [TextEditingElement._delayBeforePositining] .
769
+ bool get _canPositionInput => inputPositioned || ! doesKeyboardShiftInput;
770
+
771
+ /// Flag indicating if virtual keyboard shifts the location of input element.
772
+ ///
773
+ /// Value decided using the operating system and the browser engine.
774
+ ///
775
+ /// In IOS, the virtual keyboard might shifts the screen up to make input
776
+ /// visible depending on the location of the focused input element.
777
+ bool get doesKeyboardShiftInput =>
778
+ browserEngine == BrowserEngine .webkit &&
779
+ operatingSystem == OperatingSystem .iOs;
780
+
766
781
/// These style attributes are dynamic throughout the life time of an input
767
782
/// element.
768
783
///
769
784
/// They are changed depending on the messages coming from method calls:
770
785
/// "TextInput.setStyle", "TextInput.setEditableSizeAndTransform".
771
- ///
772
- /// In IOS, initial positionig of input element is not done in this method.
773
- /// This method changes the location of the input element if it is already
774
- /// positioned.
775
- /// See [TextEditingElement._delayBeforePositining] .
776
786
void _setDynamicStyleAttributes (html.HtmlElement domElement) {
777
- if (_editingLocationAndSize != null &&
778
- (inputPositioned ||
779
- ! (browserEngine == BrowserEngine .webkit &&
780
- operatingSystem == OperatingSystem .iOs))) {
787
+ if (_editingLocationAndSize != null && _canPositionInput) {
781
788
setStyle (domElement);
782
789
}
783
790
}
0 commit comments