Skip to content

Commit 0c302dd

Browse files
committed
Collapse when moved cursor but not selected any text
1 parent 8c77d5c commit 0c302dd

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

  • packages/ui/src/components/editor/panel/ResponsePreview/components

‎packages/ui/src/components/editor/panel/ResponsePreview/components/TextItem.tsx‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,17 @@ export const TextItem: FC<Props> = (props) => {
2424

2525
const handle_mouse_move = () => {
2626
mouse_moved.current = true
27-
28-
2927
}
3028

3129
const handle_mouse_up = () => {
32-
if (!mouse_moved.current && !has_selection.current) {
30+
const selection = window.getSelection()
31+
const has_selection_now =
32+
(selection && selection.toString().length > 0) || false
33+
34+
if (
35+
(!mouse_moved.current && !has_selection.current) ||
36+
(mouse_moved.current && !has_selection_now)
37+
) {
3338
props.on_toggle(header_ref.current!)
3439
}
3540
}

0 commit comments

Comments
 (0)