Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Custom emoji auto complete not works properly #349

Open
1 task done
MainasuK opened this issue Mar 29, 2022 · 5 comments
Open
1 task done

[BUG] Custom emoji auto complete not works properly #349

MainasuK opened this issue Mar 29, 2022 · 5 comments
Labels
Bug Something isn't working scene:compose

Comments

@MainasuK
Copy link
Contributor

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

The cursor (caret) does not jump to the head of the text view when typing custom emoji code.
Some reports the app also crashes.

Expected Behavior

The cursor keep in stand with a spacer after the inline emoji input.

Steps To Reproduce

  1. Open the Compose scene

  2. Input the custom emoji code
    :emoji_code:

  3. Type spacer or select emoji in the list

Environment

- Device: iPhone X
- OS: iOS 15.0.2
- Version: v1.3.0
- Build: 109

Anything else?

No response

@MainasuK MainasuK added Bug Something isn't working scene:compose labels Mar 29, 2022
@tjb
Copy link

tjb commented Apr 1, 2022

hey @MainasuK may I take a stab at this issue? I would like to contribute to this project when time permits.

@MainasuK
Copy link
Contributor Author

MainasuK commented Apr 2, 2022

Hi, @tjb

Yes, you can. Please check the MetaTextKit package v2 and UIInputView.insertText method. I think it's a DispatchQueue working sync issue and maybe more reasones.

Also, I will notify here when there is a patch for this in the fureture.

@tjb
Copy link

tjb commented Apr 5, 2022

hey @MainasuK i am making some progress but have some questions. I was able to get the custom emojis to render correctly however i am unable to get the cursor in the correct spot. what i am noticing is that the function that triggers

        DispatchQueue.main.async {
            self.textEditorView.textView.insertText(" ") // trigger textView delegate update
        }

the textView delegate to update causes some issues. one being that when an emoji is used, the .insertText(" ") function does indeed trigger the delegate however it does not pass in the emoji data to the delegate.

i am also a bit lost on how the emoji gets rendered from the URL in the meta data. i believe that could be where the issue is occurring..due to rendering. any guidance would be appreciated.

attached is a video showing the cursor in the wrong position.

Simulator.Screen.Recording.-.iPhone.13.-.2022-04-04.at.23.39.30.mp4

@MainasuK
Copy link
Contributor Author

MainasuK commented Apr 5, 2022

@tjb Hello, the emoji rendering is implemented by v2 MetaTextKit which using the Apple TextKit SDK.

Please check this:
https://github.com/TwidereProject/MetaTextKit/blob/3ea336d3de7938dc112084c596a646e697b0feee/Sources/MetaTextKit/MetaLayoutManager.swift#L104-L109

I guess the emoji rendering logic may break the cursor position due to the glyph range will be trimmed after character replace by emoji view.

@tjb
Copy link

tjb commented Apr 25, 2022

hey @MainasuK i gave it my best shot and learned a lot about the structure of the app (learning iOS in my free time) but still unsure where exactly the cursor position is changing since there seems to be many spots that could trigger things.

I will continue to look for a solution when I can but if someone picks this up before me that is fine too!

@MainasuK MainasuK mentioned this issue Nov 13, 2022
15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working scene:compose
Projects
None yet
Development

No branches or pull requests

2 participants