2021-07-13 19:34:43 +00:00
|
|
|
import { isMobile } from 'utils'
|
2021-07-11 12:51:01 +00:00
|
|
|
import { useEffect } from 'react'
|
|
|
|
import state from 'state'
|
|
|
|
|
|
|
|
// Send event on iOS when a user presses the "Done" key while editing
|
|
|
|
// a text element.
|
|
|
|
|
|
|
|
function handleFocusOut() {
|
|
|
|
state.send('BLURRED_EDITING_SHAPE')
|
|
|
|
}
|
|
|
|
|
|
|
|
export default function useSafariFocusOutFix(): void {
|
|
|
|
useEffect(() => {
|
2021-07-13 19:34:43 +00:00
|
|
|
if (isMobile()) {
|
2021-07-11 12:51:01 +00:00
|
|
|
document.addEventListener('focusout', handleFocusOut)
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
document.removeEventListener('focusout', handleFocusOut)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, [])
|
|
|
|
}
|