mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Web: add support for TextInputType.none (flutter/engine#26573)
This commit is contained in:
parent
a4a7e642ae
commit
1cfd4bf44a
@ -25,12 +25,17 @@ abstract class EngineInputType {
|
||||
return url;
|
||||
case 'TextInputType.multiline':
|
||||
return multiline;
|
||||
case 'TextInputType.none':
|
||||
return none;
|
||||
case 'TextInputType.text':
|
||||
default:
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
/// No text input.
|
||||
static const NoTextInputType none = NoTextInputType();
|
||||
|
||||
/// Single-line text input type.
|
||||
static const TextInputType text = TextInputType();
|
||||
|
||||
@ -76,12 +81,21 @@ abstract class EngineInputType {
|
||||
// Only apply `inputmode` in mobile browsers so that the right virtual
|
||||
// keyboard shows up.
|
||||
if (operatingSystem == OperatingSystem.iOs ||
|
||||
operatingSystem == OperatingSystem.android) {
|
||||
operatingSystem == OperatingSystem.android ||
|
||||
inputmodeAttribute == EngineInputType.none.inputmodeAttribute) {
|
||||
domElement.setAttribute('inputmode', inputmodeAttribute!);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// No text input.
|
||||
class NoTextInputType extends EngineInputType {
|
||||
const NoTextInputType();
|
||||
|
||||
@override
|
||||
final String inputmodeAttribute = 'none';
|
||||
}
|
||||
|
||||
/// Single-line text input type.
|
||||
class TextInputType extends EngineInputType {
|
||||
const TextInputType();
|
||||
|
||||
@ -860,6 +860,10 @@ abstract class DefaultTextEditingStrategy implements TextEditingStrategy {
|
||||
activeDomElement.setAttribute('type', 'password');
|
||||
}
|
||||
|
||||
if (config.inputType == EngineInputType.none) {
|
||||
activeDomElement.setAttribute('inputmode', 'none');
|
||||
}
|
||||
|
||||
config.autofill?.applyToDomElement(activeDomElement, focusedElement: true);
|
||||
|
||||
final String autocorrectValue = config.autocorrect ? 'on' : 'off';
|
||||
|
||||
@ -1580,6 +1580,9 @@ void testMain() {
|
||||
showKeyboard(inputType: 'url');
|
||||
expect(getEditingInputMode(), 'url');
|
||||
|
||||
showKeyboard(inputType: 'none');
|
||||
expect(getEditingInputMode(), 'none');
|
||||
|
||||
hideKeyboard();
|
||||
});
|
||||
|
||||
@ -1612,6 +1615,9 @@ void testMain() {
|
||||
showKeyboard(inputType: 'url');
|
||||
expect(getEditingInputMode(), 'url');
|
||||
|
||||
showKeyboard(inputType: 'none');
|
||||
expect(getEditingInputMode(), 'none');
|
||||
|
||||
hideKeyboard();
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user