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

[TableViewCell] fix height calculation based on font size #2031

Conversation

alexanderboswell
Copy link
Contributor

@alexanderboswell alexanderboswell commented May 22, 2024

Platforms Impacted

  • iOS
  • visionOS
  • macOS

Description of changes

When calculating the height of a table view cell, we are incorrectly accounting for which subtitle font to use. This means we are calculating using a font that is bigger than what is expected, meaning our table view cell is rendered larger than needed.

The fix is to ensure we only use the 3 line font if we have 3 lines, otherwise default back to the two line font, which is also the font for one line.

Binary change

N/A

Verification

Before rendered height: 66, calculated height: 64 After rendered height: 64, calculated height: 64
image image

saw the height of each cell in the view debugger and compared the value. All of these scenarios it was still as expected

regular text size

scenario Before After
single line cell 48 height Screenshot 2024-05-22 at 11 45 53 AM Screenshot 2024-05-22 at 11 39 22 AM
double line cell 64 height Screenshot 2024-05-22 at 11 46 01 AM Screenshot 2024-05-22 at 11 39 31 AM
triple line cell 84 height Screenshot 2024-05-22 at 11 46 19 AM Screenshot 2024-05-22 at 11 40 02 AM
cell without custom view 64 height Screenshot 2024-05-22 at 11 46 45 AM Screenshot 2024-05-22 at 11 40 23 AM
cell with custom accessory view 48 height Screenshot 2024-05-22 at 11 46 51 AM Screenshot 2024-05-22 at 11 40 32 AM
cell with text truncation 84 height Screenshot 2024-05-22 at 11 47 00 AM Screenshot 2024-05-22 at 11 40 40 AM
cell with text wrapping 84 height Screenshot 2024-05-22 at 11 47 08 AM Screenshot 2024-05-22 at 11 41 11 AM

Pull request checklist

This PR has considered:

  • Light and Dark appearances
  • iOS supported versions (all major versions greater than or equal current target deployment version)
  • VoiceOver and Keyboard Accessibility
  • Internationalization and Right to Left layouts
  • Different resolutions (1x, 2x, 3x)
  • Size classes and window sizes (iPhone vs iPad, notched devices, multitasking, different window sizes, etc)
  • iPad Pointer interaction
  • SwiftUI consumption (validation or new demo scenarios needed)
  • Objective-C exposure (provide it only if needed)
Microsoft Reviewers: Open in CodeFlow

@alexanderboswell alexanderboswell requested a review from a team as a code owner May 22, 2024 19:10
@alexanderboswell alexanderboswell enabled auto-merge (squash) May 22, 2024 19:11
@alexanderboswell alexanderboswell removed the request for review from joannaquu May 22, 2024 20:29
@alexanderboswell alexanderboswell disabled auto-merge May 22, 2024 20:29
@alexanderboswell alexanderboswell enabled auto-merge (squash) May 22, 2024 20:29
@joannaquu
Copy link
Contributor

should be one more case in line 1570

@alexanderboswell alexanderboswell disabled auto-merge May 22, 2024 20:47
@alexanderboswell
Copy link
Contributor Author

should be one more case in line 1570

Actually, that scenario is wrapped in

if layoutType == .twoLines || layoutType == .threeLines {
}

so there is no scenario in which we could hit that line and it be the .oneLine scenario

@alexanderboswell alexanderboswell merged commit 0a4e94b into microsoft:main May 22, 2024
7 checks passed
@alexanderboswell alexanderboswell deleted the user/alboswel/FixHeightCalculation branch May 22, 2024 22:20
@joannaquu joannaquu mentioned this pull request May 23, 2024
12 tasks
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