Skip to content

Commit

Permalink
feat(editable-title): move and scroll to the end (apache#15270)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenLYZ authored and cccs-RyanS committed Dec 17, 2021
1 parent f71766c commit 016fc31
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions superset-frontend/src/components/EditableTitle/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down

0 comments on commit 016fc31

Please sign in to comment.