Skip to content

Commit 5e5b16e

Browse files
authored
[Property Editor] Fix text input state retention issues follow-up (#8958)
1 parent 7a8c65d commit 5e5b16e

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

packages/devtools_app/lib/src/standalone_ui/ide_shared/property_editor/property_editor_inputs.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ class _DropdownInputState<T> extends State<_DropdownInput<T>>
121121
Widget build(BuildContext context) {
122122
final theme = Theme.of(context);
123123
return DropdownButtonFormField(
124-
key: Key(widget.property.hashCode.toString()),
125124
value: widget.property.valueDisplay,
126125
autovalidateMode: AutovalidateMode.onUserInteraction,
127126
validator: (text) => inputValidator(text, property: widget.property),
@@ -207,10 +206,10 @@ class _TextInputState<T> extends State<_TextInput<T>>
207206
with _PropertyInputMixin<_TextInput<T>, T>, AutoDisposeMixin {
208207
static const _paddingDiffComparedToDropdown = 1.0;
209208

210-
String _currentValue = '';
211-
212209
late final FocusNode _focusNode;
213210

211+
late String _currentValue;
212+
214213
@override
215214
void initState() {
216215
super.initState();
@@ -228,7 +227,6 @@ class _TextInputState<T> extends State<_TextInput<T>>
228227
Widget build(BuildContext context) {
229228
final theme = Theme.of(context);
230229
return TextFormField(
231-
key: Key(widget.property.hashCode.toString()),
232230
focusNode: _focusNode,
233231
initialValue: widget.property.valueDisplay,
234232
enabled: widget.property.isEditable,

packages/devtools_app/lib/src/standalone_ui/ide_shared/property_editor/property_editor_view.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,29 +193,38 @@ class _PropertyInput extends StatelessWidget {
193193
@override
194194
Widget build(BuildContext context) {
195195
final argType = property.type;
196+
final propertyKey = Key(property.hashCode.toString());
196197
switch (argType) {
197198
case boolType:
198199
return BooleanInput(
200+
key: propertyKey,
199201
property: property as FiniteValuesProperty,
200202
editProperty: editProperty,
201203
);
202204
case doubleType:
203205
return DoubleInput(
206+
key: propertyKey,
204207
property: property as NumericProperty,
205208
editProperty: editProperty,
206209
);
207210
case enumType:
208211
return EnumInput(
212+
key: propertyKey,
209213
property: property as FiniteValuesProperty,
210214
editProperty: editProperty,
211215
);
212216
case intType:
213217
return IntegerInput(
218+
key: propertyKey,
214219
property: property as NumericProperty,
215220
editProperty: editProperty,
216221
);
217222
case stringType:
218-
return StringInput(property: property, editProperty: editProperty);
223+
return StringInput(
224+
key: propertyKey,
225+
property: property,
226+
editProperty: editProperty,
227+
);
219228
default:
220229
return Text(property.valueDisplay);
221230
}

0 commit comments

Comments
 (0)