From f31d573561824043521b5081aea42620d6ac4558 Mon Sep 17 00:00:00 2001 From: Yaozong Liu <750188453@qq.com> Date: Wed, 23 Jun 2021 13:01:14 +0800 Subject: [PATCH] feat(editable-title): move and scroll to the end (#15270) --- superset-frontend/src/components/EditableTitle/index.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/superset-frontend/src/components/EditableTitle/index.tsx b/superset-frontend/src/components/EditableTitle/index.tsx index ec2245b05e..86c0350615 100644 --- a/superset-frontend/src/components/EditableTitle/index.tsx +++ b/superset-frontend/src/components/EditableTitle/index.tsx @@ -70,6 +70,13 @@ export default function EditableTitle({ useEffect(() => { if (isEditing) { contentRef.current.focus(); + // move cursor and scroll to the end + if (contentRef.current.setSelectionRange) { + const { length } = contentRef.current.value; + contentRef.current.setSelectionRange(length, length); + contentRef.current.scrollLeft = contentRef.current.scrollWidth; + contentRef.current.scrollTop = contentRef.current.scrollHeight; + } } }, [isEditing]);