-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
[iOS] Fix Label Truncation on iOS with HorizontalOptions #14453
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tj-devel709
added
platform/iOS 🍎
legacy-area-controls
Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor
area-controls-label
Label, Span
labels
Apr 7, 2023
hartez
suggested changes
Apr 7, 2023
mandel-macaque
approved these changes
Apr 7, 2023
hartez
suggested changes
Apr 7, 2023
mattleibow
reviewed
Apr 28, 2023
Thank you for your pull request. We are auto-formatting your source code to follow our code guidelines. |
mattleibow
reviewed
May 4, 2023
hartez
approved these changes
May 5, 2023
Thank you for your pull request. We are auto-formatting your source code to follow our code guidelines. |
mattleibow
approved these changes
May 8, 2023
rmarinho
pushed a commit
that referenced
this pull request
May 30, 2023
* initial fix * Add tests * round test asserts for android * add conditional for no wrap and add more tests * Adjust tests for android * do not run on windows for now * Add changes to work on Windows * limit the labels text to the parent container width and adjust tests * Auto-format source code * also add a height restriction * Auto-format source code --------- Co-authored-by: tj-devel709 <tjlambert@microsoft.com> Co-authored-by: GitHub Actions Autoformatter <autoformat@example.com>
Maybe something similar happens in #14411 ? |
Eilon
removed
the
legacy-area-controls
Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor
label
May 10, 2024
samhouts
added
the
fixed-in-8.0.0-preview.5.8529
Look for this fix in 8.0.0-preview.5.8529!
label
Aug 2, 2024
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
area-controls-label
Label, Span
fixed-in-8.0.0-preview.5.8529
Look for this fix in 8.0.0-preview.5.8529!
platform/iOS 🍎
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Change
Thank you @kunyli for uncovering that the issue of the label not staying inside the parent and not truncating properly happens when the HorizontalOption is set!
It turns out that when we have a label in iOS, it computes the desiredWidth using UIView's SizeThatFits(). This returns the full width of the label (even if it is longer than the parent view). In LayoutExtensions, it checks if the
view.HorizontalLayoutAlignment == LayoutAlignment.Fill
and if so, will use the width of the parent view. It is also worth noting that the default HorizontalOption value is fill.Therefore, when we set the HorizontalOption to anything other than fill, it does not hit this check and will set the frame based on the entire desired width of the label. Also when the label has it's longer desired width, there was no need for truncating.
The fix in this PR is to use the parent container view's width when the desired width from the label is larger.
Below are the examples from the two issues with the changes in this PR:
Issues Fixed
Fixes #9084
Fixes #14368