#929 Wrap PasteInput updates in a setTimeout (#1033)

* wrap PasteInput updates in a setTimeout

* just wrap the whole callback
This commit is contained in:
Eric Bailey 2023-07-19 12:08:40 -05:00 committed by GitHub
parent abd2c8e695
commit 4515559b1a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -79,7 +79,18 @@ export const TextInput = forwardRef(
}))
const onChangeText = useCallback(
async (newText: string) => {
(newText: string) => {
/*
* This is a hack to bump the rendering of our styled
* `textDecorated` to _after_ whatever processing is happening
* within the `PasteInput` library. Without this, the elements in
* `textDecorated` are not correctly painted to screen.
*
* NB: we tried a `0` timeout as well, but only positive values worked.
*
* @see https://github.com/bluesky-social/social-app/issues/929
*/
setTimeout(async () => {
const newRt = new RichText({text: newText})
newRt.detectFacetsWithoutResolution()
setRichText(newRt)
@ -125,6 +136,7 @@ export const TextInput = forwardRef(
if (!isEqual(set, suggestedLinks)) {
onSuggestedLinksChanged(set)
}
}, 1)
},
[
setRichText,