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

Eliminate setText call in applyNewStyles on Android #608

Merged
merged 2 commits into from
Jan 31, 2025

Conversation

tomekzaw
Copy link
Collaborator

Details

This PR refactors the implementation of applyNewStyles method on Android.

Currently, in applyNewStyles we obtain the current value using getText method and pass it to setText method in order to trigger MarkdownTextWatcher. This works fine but can lead to infinite loop because calling setText (or even setTextKeepState) generates a selection update event. In live-markdown example app, onSelectionChange callback always calls setSelection (without comparing start and end fields so it updates the reference to selection state) which results in render that leads to another applyNewStyles call (not sure how exactly, though).

Instead, we call applyMarkdownFormatting which doesn't emit selection change event.

Related Issues

Required by #607.

Manual Tests

Linked PRs

j-piasecki
j-piasecki previously approved these changes Jan 30, 2025
@tomekzaw tomekzaw merged commit 8ba4b56 into main Jan 31, 2025
5 checks passed
@tomekzaw tomekzaw deleted the @tomekzaw/apply-new-styles branch January 31, 2025 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants