🐛 Fix focus after selecting mark in text editor
This commit is contained in:
@@ -38,6 +38,7 @@ const TextBubbleEditorContent = ({
|
||||
const varDropdownRef = useRef<HTMLDivElement | null>(null)
|
||||
const rememberedSelection = useRef<BaseSelection | null>(null)
|
||||
const [isVariableDropdownOpen, setIsVariableDropdownOpen] = useState(false)
|
||||
const [isFirstFocus, setIsFirstFocus] = useState(true)
|
||||
|
||||
const textEditorRef = useRef<HTMLDivElement>(null)
|
||||
|
||||
@@ -139,14 +140,16 @@ const TextBubbleEditorContent = ({
|
||||
style: editorStyle(useColorModeValue('white', colors.gray[850])),
|
||||
autoFocus: true,
|
||||
onFocus: () => {
|
||||
if (!isFirstFocus) return
|
||||
if (editor.children.length === 0) return
|
||||
selectEditor(editor, {
|
||||
edge: 'end',
|
||||
})
|
||||
setIsFirstFocus(false)
|
||||
},
|
||||
'aria-label': 'Text editor',
|
||||
onBlur: () => {
|
||||
rememberedSelection.current = editor.selection
|
||||
rememberedSelection.current = editor?.selection
|
||||
},
|
||||
onKeyDown: handleKeyDown,
|
||||
onClick: () => {
|
||||
|
||||
@@ -41,7 +41,7 @@ export const ItemNodesList = ({
|
||||
const isDraggingOnCurrentBlock =
|
||||
(draggedItem && mouseOverBlock?.id === block.id) ?? false
|
||||
const showPlaceholders =
|
||||
draggedItem !== undefined && block.items[0].type === draggedItem.type
|
||||
draggedItem !== undefined && block.items.at(0)?.type === draggedItem.type
|
||||
|
||||
const isLastBlock =
|
||||
isDefined(typebot) &&
|
||||
|
||||
Reference in New Issue
Block a user