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

fix(text): prevent always running detect text alignment #578

Closed
wants to merge 1 commit into from

Conversation

wkashdan
Copy link
Contributor

Describe the problem this PR addresses

This pull request is meant to improve browser performance of the Text component. The current implementation causes the browser to recompute actual styles each time a text component is mounted and/or updated. This occurs only to fix an issue with letter spacing.

Describe the changes in this PR

This PR ensure the logic to detect center styling only runs if custom letter spacing is passed in to the component, otherwise there is no need to run this.

Other information

This issue frequently causes Safari to do a force layout calculation which is inefficient.

@wkashdan wkashdan requested a review from a team as a code owner March 26, 2024 17:27
@@ -227,10 +227,14 @@ export default {
* Detect if the text is center aligned and add left padding
* to balance out the letter spacing
*/
detectAlignCenter() {
detectAlignCenterAndLetterSpacing() {
if (!this.letterSpacing && !this.resolvedLetterSpacing) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

i don't think you need the !this.letterSpacing here, I think just !this.resolvedLetterSpacing is enough (since it checks this.letterSpacing under the hood).

Copy link
Collaborator

@pretzelhammer pretzelhammer left a comment

Choose a reason for hiding this comment

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

looks fine, just left minor comment

@pretzelhammer
Copy link
Collaborator

the CI checks failed because they ran against your repo (wkashdan/maker) instead of the main repo (square/maker). I added you to the Maker Contributors team so you should now have permissions to make the PR directly on square/maker where the CI checks can run properly.

@wkashdan
Copy link
Contributor Author

Closing this in favor of #579

@wkashdan wkashdan closed this Mar 26, 2024
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.

None yet

2 participants