Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

feat(Tooltip): pass the default text style down the tree#163259

Merged
auto-submit[bot] merged 1 commit intoflutter:masterfrom
kszczek:tooltip-default-text-style
Mar 4, 2025
Merged

feat(Tooltip): pass the default text style down the tree#163259
auto-submit[bot] merged 1 commit intoflutter:masterfrom
kszczek:tooltip-default-text-style

Conversation

@kszczek
Copy link
Contributor

Modify the tooltip's DefaultTextStyle to use the actual default text style picked to fit the current theme and platform instead of hardcoding the bodyMedium text style.

Closes:#163255

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel onDiscord.

@github-actionsgithub-actionsbot added frameworkflutter/packages/flutter repository. See also f: labels. f: material designflutter/packages/flutter/material repository. labelsFeb 13, 2025
@kszczekkszczek marked this pull request as draftFebruary 14, 2025 10:42
@kszczekkszczekforce-pushed thetooltip-default-text-style branch 2 times, most recently from0eb51fa toca51730CompareFebruary 14, 2025 17:04
@kszczekkszczek marked this pull request as ready for reviewFebruary 14, 2025 17:09
Copy link
Contributor

@LongCatIsLooongLongCatIsLooong left a comment

Choose a reason for hiding this comment

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

The proposal and the implementation make sense to me. Just a few questions regarding the default values.

@kszczekkszczekforce-pushed thetooltip-default-text-style branch fromca51730 to5496f7bCompareFebruary 20, 2025 09:52
@LongCatIsLooong
Copy link
Contributor

Hmm it looks like the test failures are caused by this change. Could you take a look?

kszczek reacted with thumbs up emoji

@kszczekkszczekforce-pushed thetooltip-default-text-style branch 2 times, most recently from68c5352 tob99d128CompareFebruary 21, 2025 19:41
@kszczek
Copy link
ContributorAuthor

TheTooltipThemeData tests needed some adjustments. I also added an additional assert in the new tooltip test to prevent regressions in the text style merging logic.

Copy link
Contributor

@justinmcjustinmc left a comment

Choose a reason for hiding this comment

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

LGTM with nits, thanks for the PR!

@kszczekkszczekforce-pushed thetooltip-default-text-style branch fromb99d128 toda21984CompareFebruary 26, 2025 17:24
@justinmc
Copy link
Contributor

There are Google test failures of two types:

  1. Image diff tests where the text style has changed very slightly. I think we can approve these.
  2. Text.style that was previously non-null but now is null. Any idea what caused that and what we can do about it?
kszczek reacted with eyes emoji

@kszczek
Copy link
ContributorAuthor

Text.style that was previously non-null but now is null. Any idea what caused that and what we can do about it?

Before this PR, the tooltip'sText.rich widget received its text style explicitly via thestyle parameter. However, since we've introduced aDefaultTextStyle ancestor thatText.rich can inherit from, explicitly passing the same text style has become redundant.

There are two ways we can resolve these failures:

  1. Modify the tests so that, instead of checking thestyle parameter directly on theText widget, we retrieve the firstDefaultTextStyle ancestor of theText and check itsstyle. This change should not cause any breakages in apps outside of tests because, let’s be real, does anyone actually read thestyle parameter of aText widget outside of tests?

    - final TextStyle textStyle = tester.widget<Text>(find.text(tooltipText)).style!;+ final Finder defaultTextStyle = find.ancestor(+   of: find.text(tooltipText),+   matching: find.byType(DefaultTextStyle),+ );+ final TextStyle textStyle = tester.widget<DefaultTextStyle>(defaultTextStyle.first).style;
  2. We can pass the same text style to both theDefaultTextStyle widget and theText.rich widget. This won't change the behavior but will resolve the test failures.

@LongCatIsLooong
Copy link
Contributor

Text.style that was previously non-null but now is null. Any idea what caused that and what we can do about it?

Before this PR, the tooltip'sText.rich widget received its text style explicitly via thestyle parameter. However, since we've introduced aDefaultTextStyle ancestor thatText.rich can inherit from, explicitly passing the same text style has become redundant.

There are two ways we can resolve these failures:

  1. Modify the tests so that, instead of checking thestyle parameter directly on theText widget, we retrieve the firstDefaultTextStyle ancestor of theText and check itsstyle. This change should not cause any breakages in apps outside of tests because, let’s be real, does anyone actually read thestyle parameter of aText widget outside of tests?
    - final TextStyle textStyle = tester.widget<Text>(find.text(tooltipText)).style!;+ final Finder defaultTextStyle = find.ancestor(+   of: find.text(tooltipText),+   matching: find.byType(DefaultTextStyle),+ );+ final TextStyle textStyle = tester.widget<DefaultTextStyle>(defaultTextStyle.first).style;
  2. We can pass the same text style to both theDefaultTextStyle widget and theText.rich widget. This won't change the behavior but will resolve the test failures.

This by definition is a breaking change (it affects registered tests). Arguably the tests could have been improved so it does not rely on implementation details but I would recommend avoiding the breaking change for now, by defaulting toDefaultTextStyle.

As for the failing golden image tests, it could be a flake or it could be a legitimate typeface change introduced by.merge(tooltipTheme.textStyle).merge(widget.textStyle). Let's see if it persists when you push another commit.

kszczek reacted with thumbs up emoji

@kszczekkszczekforce-pushed thetooltip-default-text-style branch 2 times, most recently from7bc7909 to7184bf5CompareMarch 3, 2025 22:00
@kszczek
Copy link
ContributorAuthor

This by definition is a breaking change (it affects registered tests). Arguably the tests could have been improved so it does not rely on implementation details but I would recommend avoiding the breaking change for now, by defaulting to DefaultTextStyle.

I agree, done!

As for the failing golden image tests, it could be a flake or it could be a legitimate typeface change introduced by.merge(tooltipTheme.textStyle).merge(widget.textStyle). Let's see if it persists when you push another commit.

Unfortunately Google tests are still failing and I'm afraid what you're saying about the typefaces changing might be the case. Would that also be considered a breaking change?

onExit: _handleMouseExit,
decoration: widget.decoration ?? tooltipTheme.decoration ?? defaultDecoration,
textStyle:widget.textStyle ??tooltipTheme.textStyle ?? defaultTextStyle,
textStyle:defaultTextStyle.merge(tooltipTheme.textStyle).merge(widget.textStyle),
Copy link
Contributor

Choose a reason for hiding this comment

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

could you try(tooltipTheme.textStyle ?? defaultTextStyle).merge(widget.textStyle) and see if it still affects the test images?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Still no luck. It might be best to put the text style merging on hold for now and proceed with just the following change:

child: DefaultTextStyle(- style: Theme.of(context).textTheme.bodyMedium!,+ style: textStyle,+ textAlign: textAlign,

This would resolve the original issue, which was that the default text style didn't reach all the way down to text widgets hidden beneath widget spans.

We can open a separate issue for the breaking change related to text style merging, and later decide whether to proceed with it. What do you think?

LongCatIsLooong reacted with thumbs up emoji
@kszczekkszczekforce-pushed thetooltip-default-text-style branch 6 times, most recently from7083790 to9b533c5CompareMarch 4, 2025 16:50
@LongCatIsLooong
Copy link
Contributor

Looks like the tests are passing, thank you for your patience 🙏

kszczek reacted with hooray emoji

@auto-submitauto-submitbot added this pull request to themerge queueMar 4, 2025
Merged via the queue intoflutter:master with commit612d39eMar 4, 2025
75 checks passed
@flutter-dashboardflutter-dashboardbot removed the autosubmitMerge PR when tree becomes green via auto submit App labelMar 4, 2025
@kszczekkszczek deleted the tooltip-default-text-style branchMarch 4, 2025 22:45
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@LongCatIsLooongLongCatIsLooongLongCatIsLooong approved these changes

@justinmcjustinmcjustinmc approved these changes

Assignees

No one assigned

Labels

f: material designflutter/packages/flutter/material repository.frameworkflutter/packages/flutter repository. See also f: labels.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Tooltip's default text style should be passed down to widget spans

3 participants

@kszczek@LongCatIsLooong@justinmc

[8]ページ先頭

©2009-2026 Movatter.jp