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

Implement extension function to remove orphan words #566

Merged
merged 2 commits into from
Jan 29, 2025

Conversation

AdamGrzybkowski
Copy link
Contributor

@AdamGrzybkowski AdamGrzybkowski commented Jan 28, 2025

Closes #565

Description

This PR adds a String extension that inserts a non-breaking space before the last word to make sure no orphan words are left in the last line. It's used in the QESectionMessage

Testing Steps

  1. Launch the QE
  2. In the Avatar picker play with the font scaling and make sure the text Choose or upload your favorite avatar images and connect them to your email address. will never have orphans.

@AdamGrzybkowski AdamGrzybkowski added Enhance Enhancement [Feature] Gravatar-Quickeditor Gravatar Quick Editor module labels Jan 28, 2025
@AdamGrzybkowski AdamGrzybkowski added this to the 2.3.0 milestone Jan 28, 2025
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Jan 28, 2025

📲 You can test the changes from this Pull Request in Gravatar Demo by scanning the QR code below to install the corresponding build.
App Name Gravatar Demo
Commit7eba37b
Direct Downloadgravatar-demo-prototype-build-pr566-7eba37b.apk

@AdamGrzybkowski AdamGrzybkowski force-pushed the adam/565_orphans branch 2 times, most recently from 1a74283 to 3b8a117 Compare January 28, 2025 12:06
@mlumeau
Copy link
Member

mlumeau commented Jan 28, 2025

I like this in principle, but I'm not sure we need a new composable for that. We could just keep the extension function from this PR and apply it to every Text where we need it?
What if the Text composable evolves and adds new attributes in the future? We'll need to keep up then.

@AdamGrzybkowski
Copy link
Contributor Author

What if the Text composable evolves and adds new attributes in the future? We'll need to keep up then.

That makes sense, I will remove it.

@AdamGrzybkowski AdamGrzybkowski changed the title Implement QEText that will remove orphan words Implement extension function to remove orphan words Jan 28, 2025
@@ -0,0 +1,8 @@
package com.gravatar.quickeditor.ui

internal val String.removeOrphans: String
Copy link
Member

Choose a reason for hiding this comment

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

Can we add a unit test for this function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure!

Copy link
Member

@mlumeau mlumeau left a comment

Choose a reason for hiding this comment

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

LGTM!

@AdamGrzybkowski AdamGrzybkowski merged commit 873de57 into trunk Jan 29, 2025
17 checks passed
@AdamGrzybkowski AdamGrzybkowski deleted the adam/565_orphans branch January 29, 2025 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhance Enhancement [Feature] Gravatar-Quickeditor Gravatar Quick Editor module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Orphans in text fields
3 participants