UBERF-8145 Do not focus on editor when adding a table (#6598)

Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
Alexander Onnikov 2024-09-17 16:39:08 +07:00 committed by GitHub
parent 66db3ac029
commit c51122ac8d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -333,11 +333,14 @@
targetItem instanceof MouseEvent ? getEventPositionElement(targetItem) : getPopupPositionElement(targetItem)
}
// addTableHandler opens popup so the editor loses focus
// so in the callback we need to refocus again
void addTableHandler((options: { rows?: number, cols?: number, withHeaderRow?: boolean }) => {
editor.chain().insertTable(options).focus(pos).run()
}, position)
// We need to trigger it asynchronously in order for the editor to finish its focus event
// Otherwise, it hoggs the focus from the popup and keyboard navigation doesn't work
setTimeout(() => {
// addTableHandler opens popup so the editor loses focus so in the callback we need to refocus again
void addTableHandler((options: { rows?: number, cols?: number, withHeaderRow?: boolean }) => {
editor.chain().focus(pos).insertTable(options).run()
}, position)
}, 0)
break
}
case 'code-block':