Repository: ianstormtaylor/slate
File: packages/slate-react/src/components/editable.tsx (TypeScript)

Code before:
                  if (readOnly) {
                    return
                  }

                  const start = Editor.start(editor, path)
                  const end = Editor.end(editor, path)
                  const startVoid = Editor.void(editor, { at: start })
                  const endVoid = Editor.void(editor, { at: end })

                  if (
                    startVoid &&
                    endVoid &&
                    Path.equals(startVoid[1], endVoid[1])
                  ) {
                    const range = Editor.range(editor, start)
                    Transforms.select(editor, range)
                  }
                }
              },
              [editor, attributes.onClick, readOnly]
            )}
            onCompositionEnd={useCallback(
              (event: React.CompositionEvent<HTMLDivElement>) => {
                if (ReactEditor.hasSelectableTarget(editor, event.target)) {
                  if (ReactEditor.isComposing(editor)) {
                    Promise.resolve(()=>{
                      setIsComposing(false)
                      IS_COMPOSING.set(editor, false)
                    })
                  }

                  androidInputManagerRef.current?.handleCompositionEnd(event)

                  if (
                    isEventHandled(event, attributes.onCompositionEnd) ||
                    IS_ANDROID
                  ) {
                    return
                  }

                  // COMPAT: In Chrome, `beforeinput` events for compositions
                  // aren't correct and never fire the "insertFromComposition"
                  // type that we need. So instead, insert whenever a composition
                  // ends since it will already have been committed to the DOM.
                  if (
                    !IS_WEBKIT &&
                    !IS_FIREFOX_LEGACY &&
                    !IS_IOS &&
                    !IS_WECHATBROWSER &&
                    !IS_UC_MOBILE &&
                    event.data

Review comment (suggestion):
```suggestion
                    Promise.resolve(() => {
```

Code after:
                  if (readOnly) {
                    return
                  }

                  const start = Editor.start(editor, path)
                  const end = Editor.end(editor, path)
                  const startVoid = Editor.void(editor, { at: start })
                  const endVoid = Editor.void(editor, { at: end })

                  if (
                    startVoid &&
                    endVoid &&
                    Path.equals(startVoid[1], endVoid[1])
                  ) {
                    const range = Editor.range(editor, start)
                    Transforms.select(editor, range)
                  }
                }
              },
              [editor, attributes.onClick, readOnly]
            )}
            onCompositionEnd={useCallback(
              (event: React.CompositionEvent<HTMLDivElement>) => {
                if (ReactEditor.hasSelectableTarget(editor, event.target)) {
                  if (ReactEditor.isComposing(editor)) {
                    Promise.resolve(() => {
                      setIsComposing(false)
                      IS_COMPOSING.set(editor, false)
                    })
                  }

                  androidInputManagerRef.current?.handleCompositionEnd(event)

                  if (
                    isEventHandled(event, attributes.onCompositionEnd) ||
                    IS_ANDROID
                  ) {
                    return
                  }

                  // COMPAT: In Chrome, `beforeinput` events for compositions
                  // aren't correct and never fire the "insertFromComposition"
                  // type that we need. So instead, insert whenever a composition
                  // ends since it will already have been committed to the DOM.
                  if (
                    !IS_WEBKIT &&
                    !IS_FIREFOX_LEGACY &&
                    !IS_IOS &&
                    !IS_WECHATBROWSER &&
                    !IS_UC_MOBILE &&
                    event.data