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

Fixed iOS button flickering animation with is Top or Bottom ContentLayout when text it updated at run time #25662

Closed
wants to merge 9 commits into from

Conversation

NirmalKumarYuvaraj
Copy link
Contributor

@NirmalKumarYuvaraj NirmalKumarYuvaraj commented Nov 4, 2024

Issue Details

Modifying a button's text from a long string to a short one (or vice versa) with the image and content layout set to 'Top' causes the image to shift momentarily from the center to the start position before returning to the center.

Root Cause

When the button content layout is set to 'top' or 'bottom,' the ImageInsets adjusts based on the text width. Whenever the text width changes, this causes the ImageInsets to be modified in real-time, resulting in an image flicker when updating the text.

Description of Change

If the content layout is set to 'Top' or 'Bottom,' we can calculate the image insets for the button based on its width and the image width.

Validated the behaviour in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Issues Fixed

Fixes #25487

Output

Before After
Before.IOS.mov
After.IOS.mov
Before.MAC.mov
After.Mac.mov

Android

Android.mov

@jsuarezruiz jsuarezruiz added area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter area-controls-button Button, ImageButton labels Nov 6, 2024
@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@tj-devel709
Copy link
Member

Very interesting find :)

@NirmalKumarYuvaraj NirmalKumarYuvaraj marked this pull request as ready for review November 14, 2024 10:30
@NirmalKumarYuvaraj NirmalKumarYuvaraj requested a review from a team as a code owner November 14, 2024 10:30
@jsuarezruiz
Copy link
Contributor

jsuarezruiz commented Nov 15, 2024

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@NirmalKumarYuvaraj
Copy link
Contributor Author

Compared to the previous button content alignment behavior, my fix causes the image to shift by 1 pixel. As a result, some test cases failed on the iOS platform. Therefore, I replaced the images with new ones generated by CI.

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@jsuarezruiz
Copy link
Contributor

jsuarezruiz commented Nov 26, 2024

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@Redth Redth requested a review from tj-devel709 December 4, 2024 17:21
@Redth
Copy link
Member

Redth commented Dec 4, 2024

/rebase

@Redth
Copy link
Member

Redth commented Dec 4, 2024

@tj-devel709 this looks like a reasonable change to me... any concerns with the approach here?

@Redth Redth requested a review from Copilot December 4, 2024 21:49

Choose a reason for hiding this comment

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

Copilot reviewed 21 out of 22 changed files in this pull request and generated no suggestions.

Files not reviewed (1)
  • src/Controls/tests/TestCases.HostApp/Issues/Issue25487.xaml: Language not supported
Comments skipped due to low confidence (2)

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue25487.cs:18

  • The test case should explicitly verify that the flickering issue is resolved by checking the button's position before and after the text change.
App.Tap("ToggleTextButton");

src/Controls/tests/TestCases.HostApp/Issues/Issue25487.xaml.cs:11

  • [nitpick] The variable name '_isToggled' is ambiguous. It should be renamed to '_isButtonTextToggled' to better describe its purpose.
bool _isToggled;
@NirmalKumarYuvaraj NirmalKumarYuvaraj added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Dec 6, 2024
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@NirmalKumarYuvaraj NirmalKumarYuvaraj changed the title Fixed iOS button flickering animation when layout updates Fixed iOS button flickering animation with ContentLayout is Top or Bottom when text it updated at run time Dec 18, 2024
@NirmalKumarYuvaraj NirmalKumarYuvaraj changed the title Fixed iOS button flickering animation with ContentLayout is Top or Bottom when text it updated at run time Fixed iOS button flickering animation with is Top or Bottom ContentLayout when text it updated at run time Dec 18, 2024
@sheiksyedm
Copy link

This PR issue has already been resolved with this PR #26018, so we can close it.

@sheiksyedm sheiksyedm closed this Jan 6, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Feb 5, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-button Button, ImageButton area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter partner/syncfusion Issues / PR's with Syncfusion collaboration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

iOS Button Flickering Animations when Layout Updates
5 participants