Skip to content

Commit

Permalink
fix: text update bug on number/url fields (#5315)
Browse files Browse the repository at this point in the history
  • Loading branch information
richardshiue committed May 13, 2024
1 parent 8273d66 commit 027ab2c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,19 +163,18 @@ class _TextCellState extends State<TextCardCell> {
return BlocBuilder<TextCellBloc, TextCellState>(
builder: (context, state) {
final content = state.content;
final text = content.isEmpty
? LocaleKeys.grid_row_textPlaceholder.tr()
: content;
final color = content.isEmpty ? Theme.of(context).hintColor : null;

return Padding(
padding: widget.style.padding,
child: Text(
text,
style: widget.style.textStyle.copyWith(color: color),
maxLines: widget.style.maxLines,
),
);

return content.isEmpty
? const SizedBox.shrink()
: Container(
padding: widget.style.padding,
alignment: AlignmentDirectional.centerStart,
child: Text(
content,
style: widget.style.textStyle,
maxLines: widget.style.maxLines,
),
);
},
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,11 @@ class _NumberCellState extends GridEditableTextCell<EditableNumberCell> {
return BlocProvider.value(
value: cellBloc,
child: BlocListener<NumberCellBloc, NumberCellState>(
listener: (context, state) =>
_textEditingController.text = state.content,
listener: (context, state) {
if (!focusNode.hasFocus) {
_textEditingController.text = state.content;
}
},
child: Builder(
builder: (context) {
return widget.skin.build(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,10 @@ class _GridURLCellState extends GridEditableTextCell<EditableURLCell> {
child: BlocListener<URLCellBloc, URLCellState>(
listenWhen: (previous, current) => previous.content != current.content,
listener: (context, state) {
_textEditingController.value =
_textEditingController.value.copyWith(text: state.content);
if (!focusNode.hasFocus) {
_textEditingController.value =
_textEditingController.value.copyWith(text: state.content);
}
widget._cellDataNotifier.value = state.content;
},
child: widget.skin.build(
Expand Down

0 comments on commit 027ab2c

Please sign in to comment.