Skip to content

Conversation

@dnfield
Copy link
Contributor

@dnfield dnfield commented Mar 15, 2023

Fixes #122750

@flutter-dashboard flutter-dashboard bot added a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels. labels Mar 15, 2023
/// 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)
Copy link
Contributor Author

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

Copy link
Contributor

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:

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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?

Copy link
Contributor Author

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)

Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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() {
Copy link
Contributor

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?

Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

@mdebbar mdebbar left a 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!

@dnfield dnfield added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 16, 2023
Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

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

LGTM

@dnfield dnfield merged commit 28f17d3 into flutter:master Mar 21, 2023
@dnfield dnfield deleted the bold_text branch March 21, 2023 04:08
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 21, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 10, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: text input Entering text in a text field or keyboard related problems autosubmit Merge PR when tree becomes green via auto submit App framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EditableText does not respect MediaQuery.boldTextOf(context).

4 participants