-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Make EditableText respect MediaQuery.boldTextOf #122754
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
Conversation
| /// By default makes text in composing range appear as underlined. | ||
| /// Descendants can override this method to customize appearance of text. | ||
| TextSpan buildTextSpan() { | ||
| final TextStyle style = MediaQuery.boldTextOf(context) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are other codepaths in this file that talk to the platform channel about text style. I'm not clear on whether those need to be updated as well. @LongCatIsLooong or @mdebbar may know
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like SelectableText is already doing this:
flutter/packages/flutter/lib/src/material/selectable_text.dart
Lines 680 to 682 in 7ce6dda
| if (MediaQuery.boldTextOf(context)) { | |
| effectiveTextStyle = effectiveTextStyle.merge(const TextStyle(fontWeight: FontWeight.bold)); | |
| } |
So maybe TextField/CupertinoTextField are better places for this? Usually styles are resolved there iirc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, SelectableText does this, but EditableText does not.
If we do it higher up in the stack, couldn't some custom text editing class end up missing out? This seems like the right peer of SelectableText to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohh, I see what you're saying now.
Why not do this on EditableText and remove it from SelectableText?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I removed the call from SelectableText - I had seen it before but missed the part where SelectableText just returns an EditableText anyway)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok. I was worried about not being able to opt-out but people can just add another MediaQuery. But I think TextInputConnection.setTextStyle needs to be updated as well. Also is this supposed to affect things like suffix text or placeholder text in InputDecorator?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok those are Text widgets. But I think TextInputConnection.setTextStyle still needs to be updated with the right font weight if boldText is on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SG, I will do that and update the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| /// | ||
| /// This makes sure that accessibility settings related to bold text are | ||
| /// respected. | ||
| TextStyle updateStyleForBold() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should the update function be called in didChangeDependencies and cache the value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also this should probably be private
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deleted this method and just inlined it into didChangeDependencies and didUpdateWidget.
mdebbar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As long as we continue to send style updates to the engine, this looks good to me from web point of view!
chunhtai
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Fixes #122750