Skip to content

fix(Android): recalculating layout after changing html styles - #233

Merged
exploIF merged 10 commits into
software-mansion:mainfrom
IvanIhnatsiuk:fix/initial-hmtl-styles-are-not-applied
Dec 17, 2025
Merged

exploIF merged 10 commits into
software-mansion:mainfrom
IvanIhnatsiuk:fix/initial-hmtl-styles-are-not-applied

Conversation

@IvanIhnatsiuk

Copy link
Copy Markdown
Contributor

Description

If we change the HTML styles on Android, they will not be applied in any way until we first enter any styles. We also got a bug with the initial defaultValue, because everything started to depend on who was the first to be counted (it depends on who was the first to be passed from JS to the component).
Thus, I added the calculation of the lead when changing the HTML style on Android.

Videos

Before:

Screen.Recording.2025-11-07.at.19.24.38.mov
Screen.Recording.2025-11-07.at.19.16.29.mov

After:

Screen.Recording.2025-11-07.at.19.25.20.mov

@exploIF

exploIF commented Nov 10, 2025

Copy link
Copy Markdown
Collaborator

@IvanIhnatsiuk thanks for this, as this PR can have some impact on apps which are already using library, I would like to discuss this a little bit more. It would be super cool if you can catch up with me on discord (username exploif) or on x.com (username is linked in my profile )

@exploIF exploIF left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tested how it works when htmlStyle is defined inside render? Even if it's memoized it can be re-rendered. I'm afraid it may not work properly in such scenario, because of pretty simple detection if html style has been updated

Comment thread android/src/main/java/com/swmansion/enriched/EnrichedTextInputView.kt Outdated
Comment thread android/src/main/java/com/swmansion/enriched/EnrichedTextInputView.kt Outdated
@IvanIhnatsiuk
IvanIhnatsiuk force-pushed the fix/initial-hmtl-styles-are-not-applied branch from 6762946 to f6f54e4 Compare December 8, 2025 20:44

@exploIF exploIF left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like this approach, we just need couple minor adjustments

Comment thread example/src/App.tsx Outdated
Comment thread example/src/App.tsx Outdated
Comment thread example/src/App.tsx Outdated
Comment thread android/src/main/java/com/swmansion/enriched/EnrichedTextInputView.kt Outdated
Comment thread android/src/main/java/com/swmansion/enriched/EnrichedTextInputView.kt Outdated
Comment thread example/src/App.tsx Outdated
Comment thread example/src/App.tsx Outdated
Comment thread android/src/main/java/com/swmansion/enriched/EnrichedTextInputView.kt Outdated
@kacperzolkiewski

Copy link
Copy Markdown
Collaborator

Hi @IvanIhnatsiuk,
I found some bug during tests, that content disappears until I focus the input:

Screen.Recording.2025-12-12.at.10.43.12.mov

@IvanIhnatsiuk

Copy link
Copy Markdown
Contributor Author

@kacperzolkiewski I don't think it disappears, it looks like the layout is not updated 🤔

@IvanIhnatsiuk
IvanIhnatsiuk force-pushed the fix/initial-hmtl-styles-are-not-applied branch from f6f54e4 to 04510f3 Compare December 12, 2025 12:16
@IvanIhnatsiuk

Copy link
Copy Markdown
Contributor Author

@kacperzolkiewski could you check on the latest branch version?

@kacperzolkiewski

kacperzolkiewski commented Dec 12, 2025

Copy link
Copy Markdown
Collaborator

@IvanIhnatsiuk unfortunately still the same, it looks like it is not scrolling to the top:

Screen.Recording.2025-12-12.at.13.42.12.mov

@IvanIhnatsiuk
IvanIhnatsiuk force-pushed the fix/initial-hmtl-styles-are-not-applied branch from 04510f3 to c31c37b Compare December 15, 2025 16:46
@IvanIhnatsiuk

Copy link
Copy Markdown
Contributor Author

@IvanIhnatsiuk unfortunately still the same, it looks like it is not scrolling to the top:

Screen.Recording.2025-12-12.at.13.42.12.mov

could you retest on the latest branch version?

@kacperzolkiewski

Copy link
Copy Markdown
Collaborator

Works fine now 👏

@exploIF exploIF left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I've pushed couple tiny changes (mostly code style related)

@exploIF
exploIF merged commit 7f6c535 into software-mansion:main Dec 17, 2025
5 checks passed
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.

3 participants