Skip to content

Commit

Permalink
Fix rendering issue when tapping another cell after editing a cell.
Browse files Browse the repository at this point in the history
  • Loading branch information
bosskmk committed Jan 26, 2023
1 parent 006d751 commit 8dfcc65
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 27 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [6.0.1] - 2023. 1. 26

* Fix rendering issue when tapping another cell after editing a cell.

## [6.0.0] - 2023. 1. 26

* Updated for flutter 3.7 version.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## PlutoGrid for flutter - v6.0.0
## PlutoGrid for flutter - v6.0.1

[![Awesome Flutter](https://img.shields.io/badge/Awesome-Flutter-blue.svg)](https://github.com/Solido/awesome-flutter)
[![codecov](https://codecov.io/gh/bosskmk/pluto_grid/branch/master/graph/badge.svg)](https://codecov.io/gh/bosskmk/pluto_grid)
Expand Down
40 changes: 15 additions & 25 deletions lib/src/ui/cells/text_cell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,29 +69,25 @@ mixin TextCellState<T extends TextCell> on State<T> implements TextFieldProps {

@override
void dispose() {
_debounce.dispose();

_textController.dispose();

cellFocus.dispose();

/**
* Saves the changed value when moving a cell while text is being input.
* if user do not press enter key, onEditingComplete is not called and the value is not saved.
*/
if (_cellEditingStatus.isChanged) {
WidgetsBinding.instance.addPostFrameCallback((_) {
_changeValue(notify: false);

widget.stateManager.notifyListenersOnPostFrame();
});
_changeValue();
}

if (!widget.stateManager.isEditing ||
widget.stateManager.currentColumn?.enableEditingMode != true) {
widget.stateManager.setTextEditingController(null);
}

_debounce.dispose();

_textController.dispose();

cellFocus.dispose();

super.dispose();
}

Expand Down Expand Up @@ -137,28 +133,22 @@ mixin TextCellState<T extends TextCell> on State<T> implements TextFieldProps {
return false;
}

void _changeValue({bool notify = true}) {
void _changeValue() {
if (formattedValue == _textController.text) {
return;
}

widget.stateManager.changeCellValue(
widget.cell,
_textController.text,
notify: notify,
);
widget.stateManager.changeCellValue(widget.cell, _textController.text);

if (notify) {
_textController.text = formattedValue;
_textController.text = formattedValue;

_initialCellValue = _textController.text;
_initialCellValue = _textController.text;

_textController.selection = TextSelection.fromPosition(
TextPosition(offset: _textController.text.length),
);
_textController.selection = TextSelection.fromPosition(
TextPosition(offset: _textController.text.length),
);

_cellEditingStatus = _CellEditingStatus.updated;
}
_cellEditingStatus = _CellEditingStatus.updated;
}

void _handleOnChanged(String value) {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: pluto_grid
description: PlutoGrid is a dataGrid that can be controlled by the keyboard on desktop and web. Of course, it works well on Android and IOS. (DataGrid, DataTable, Data Grid, Data Table, Sticky)
version: 6.0.0
version: 6.0.1
homepage: https://pluto.weblaze.dev
repository: https://github.com/bosskmk/pluto_grid

Expand Down

0 comments on commit 8dfcc65

Please sign in to comment.