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 alignment for MultilineTextInput on Android #1808

Conversation

t-arn
Copy link
Contributor

@t-arn t-arn commented Mar 10, 2023

This PR fixes the issue #1807 by removing following code in the set_alignment method of the Android implementation:

        # Refuse to set alignment unless widget has been added to a container.
        # This is because Android EditText requires LayoutParams before
        # setGravity() can be called.
        if not self.native.getLayoutParams():
            return

Although the remark claims that this save guard is needed, I cannot find any problem when removing it.

PR Checklist:

  • All new features have been tested
  • All new features have been documented
  • I have read the CONTRIBUTING.md file
  • I will abide by the code of conduct

@t-arn
Copy link
Contributor Author

t-arn commented Mar 10, 2023

@mhsmith Please review this PR

@mhsmith
Copy link
Member

mhsmith commented Mar 12, 2023

Thanks, I'll have a look at this. The code in question was actually added by you in #1591. Did you notice any need for it at that time, or were you only copying it from textinput.py?

The code in textinput.py was added by @paulproteus in #1005, but a lot has changed since then.

@t-arn
Copy link
Contributor Author

t-arn commented Mar 12, 2023

Yes, I also saw that I am to blame for this code. I actually did copy it from textinput. In my own dev branch I fixed it long ago and I never had problems since.

Copy link
Member

@freakboy3742 freakboy3742 left a comment

Choose a reason for hiding this comment

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

Definitely seems to work in my testing too; I think there's been a few tweaks to the way layouts happen that have made this particular piece of protection code unnecessary.

@mhsmith
Copy link
Member

mhsmith commented May 22, 2023

#1938 removes this code from the set_alignment methods of all other widgets. However, similar code still remains in the rehint methods, which may be unnecessary.

@t-arn t-arn deleted the multilinetextinput_gravity_fix_Android_4f6f7ab branch August 6, 2023 10:44
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