Skip to content

Commit

Permalink
fix: refactor _onSelectionChange method to update _showPlaceholder st…
Browse files Browse the repository at this point in the history
…ate more efficiently
  • Loading branch information
LucasXu0 committed Aug 23, 2023
1 parent 6b15d6c commit f4db21c
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,12 @@ class _TextBlockComponentWidgetState extends State<TextBlockComponentWidget>
}

void _onSelectionChange() {
setState(() {
final selection = editorState.selection;
_showPlaceholder = selection != null &&
(selection.isSingle && selection.start.path.equals(node.path));
});
final selection = editorState.selection;
final showPlaceholder = selection != null &&
(selection.isSingle && selection.start.path.equals(node.path));
if (showPlaceholder != _showPlaceholder) {
setState(() => _showPlaceholder = showPlaceholder);
}
}

@override
Expand Down

0 comments on commit f4db21c

Please sign in to comment.