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

NSAttributedString not updating when style changes and text is highlighted #190

Open
MatthewWaller opened this issue Sep 6, 2024 · 1 comment
Labels
discussion Discussions not yet turned into an action

Comments

@MatthewWaller
Copy link

Hello. I have a setup where the I highlight some text in the RichTextEditor, and then make it bold. I'm listening for changes to the attributedString, and if there is a change, I persist it.

Here are the steps and issue I'm seeing. I'm on 1.0.0, on iOS.

  1. Use RichTextEditor to write some text.
  2. Listen for changes to the attributedString with onChange(context.attributedString
  3. Select a range of text.
  4. Use RichTextKeyboardToolbar to make the text bold.
  5. Notice that the text is bold and onChange did not fire.
  6. Deselect the text.
  7. Notice now that the onChange method did fire.

Expected result:

  • The onChange method should fire after the user makes the text bold.
    Actual result:
  • The onChange method only fires after the user deselects the text.

Any work arounds?

@danielsaidi
Copy link
Owner

danielsaidi commented Sep 9, 2024

Hi @MatthewWaller

Thank you for reporting this.

I think the reason to why this doesn't work is that (if I remember correctly) the text binging is not updated continuously, since it would cause the text editor to redraw. Instead, it's synced at certain points.

I'm currently swamped with other projects, but I'll revisit this once iOS 18 is out. My idea is to actually change the text binding at all times, but have a second decoupled text binding that is bound to the editor.

@danielsaidi danielsaidi added the discussion Discussions not yet turned into an action label Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Discussions not yet turned into an action
Projects
None yet
Development

No branches or pull requests

2 participants