-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Fix Regression with iOS button resizing with text or image change #25122
Conversation
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
2e8301f
to
837260b
Compare
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was a little confused about this image, but testing on main, this also fails in the same pixel off way as here. I think this is okay
|
||
// _isFirstMeasure is a flag to make sure we manually recalculate the titleRect when there are dynamic changes to the button. | ||
// There are times the platformButton.TitleLabel is updated on dynamic changes and reacts to the change by truncating the label when we actually | ||
// have space in our constraints. We provide the space to be used in our first measure of the titleRect and then use the newly laid out titleRect in later iterations. | ||
bool _isFirstMeasure = true; | ||
internal bool _isFirstMeasure = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of making this internal can we add a method that gets called?
ResetToFirstMeasureOfNewContent()
Or something of that nature?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah good idea!
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tj-devel709 The image in the last button (Button 2) has moved a few pixel from the center to the right. Its no longer centered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this is true. The way it was working prior to this PR worked pretty well when we would create a button, but it had some regressions with things on the button changing dynamically such as the text changing. It also led to some inconsistent behavior. The changes in this PR try to manually measure the title of the button when laying it out instead of using the UIButton.TitleLabel.Bounds since that UIButton.TitleLabel.Bounds is not updated right away when these dynamic changes happen. In .NET8 SR8 and before, it also used this same manually measure process but there are a few more optimizations now that will get the measuring and alignment a lot closer in most cases. There will be a few cases where the image may be a pixel off (particularly when the image is on top or bottom of the text of the button) and this will be corrected in the future.
/backport to 8.0.1xx-sr9 |
Started backporting to 8.0.1xx-sr9: https://github.com/dotnet/maui/actions/runs/11298662578 |
@tj-devel709 an error occurred while backporting to 8.0.1xx-sr9, please check the run log for details! Error: @tj-devel709 is not a repo collaborator, backporting is not allowed. If you're a collaborator please make sure your dotnet team membership visibility is set to Public on https://github.com/orgs/dotnet/people?query=tj-devel709 |
/backport to 8.0.1xx-sr9 |
Started backporting to 8.0.1xx-sr9: https://github.com/dotnet/maui/actions/runs/11298681931 |
@tj-devel709 an error occurred while backporting to 8.0.1xx-sr9, please check the run log for details! The process '/usr/bin/git' failed with exit code 1 |
Manually backported here to SR9 here: #25214 |
Description of Change
This PR fixes a regression with iOS buttons re-updating the size of the button when the text changes. There was some code that was trying to use the UIButton.TitleLabel.Bounds for sizing, but there are times the TitleLabel is still set to the old title. This PR also allows changes to the button size when the image is changed.
Issues Fixed
Fixes #25074
Small demo showing changing text and images triggers a resize when needed. The small jump in animation was already there and is not new to this PR.
Screen.Recording.2024-10-07.at.4.01.35.PM.mov