From 032da5021737ad55eeba66c5192c229a92942aaf Mon Sep 17 00:00:00 2001 From: Huan Du Date: Wed, 24 Jul 2024 21:38:21 +0800 Subject: [PATCH] fix: invalid selection when tapping placeholder text --- lib/src/editor/editor.dart | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/src/editor/editor.dart b/lib/src/editor/editor.dart index 271a6d55..72b8fad7 100644 --- a/lib/src/editor/editor.dart +++ b/lib/src/editor/editor.dart @@ -10,6 +10,7 @@ import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; import '../common/utils/platform.dart'; +import '../document/attribute.dart'; import '../document/document.dart'; import '../document/nodes/container.dart' as container_node; import '../document/nodes/leaf.dart'; @@ -984,6 +985,13 @@ class RenderEditor extends RenderEditableContainerBox start: localWord.start + nodeOffset, end: localWord.end + nodeOffset, ); + + // Don't change selection if the selected word is a placeholder. + if (child.container.style.attributes + .containsKey(Attribute.placeholder.key)) { + return; + } + if (position.offset - word.start <= 1 && word.end != position.offset) { _handleSelectionChange( TextSelection.collapsed(offset: word.start),