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

feat(Tooltip): replace the height parameter with constraints #163314

Merged
merged 1 commit into from
Mar 17, 2025

Conversation

kszczek
Copy link
Contributor

@kszczek kszczek commented Feb 14, 2025

Introduce a new constraints parameter, which constrains the size of the tooltip's message and deprecate the now obsolete height parameter. Do the same for the theme data, while also making some minor changes to the docs to clear up some misconceptions about which properties apply to the tooltip's message and which to the tooltip's child.

To make the transition from height to constraints as easy as possible for our users, introduce fix data to do this replacement automatically in the IDE.

Closes: #163313

Pre-launch Checklist

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

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos c: tech-debt Technical debt, code quality, testing, etc. labels Feb 14, 2025
@kszczek kszczek force-pushed the tooltip-constraints branch 2 times, most recently from e9327ea to 40ae181 Compare February 14, 2025 16:32
@kszczek kszczek force-pushed the tooltip-constraints branch 4 times, most recently from 9590a8a to 054c46f Compare February 20, 2025 11:11
@kszczek

This comment was marked as resolved.

@Piinks
Copy link
Contributor

Piinks commented Feb 25, 2025

Hey @kszczek I think where you have 'null' in the fix yaml, it should be ''. In dart fix I don't think it will evaluate these arguments as null, they will just be blank.

@Piinks
Copy link
Contributor

Piinks commented Feb 25, 2025

Also, I am not sure some of this is written in the way we expect the code to be

 - if: "height == 'null'"
        changes:
          - kind: "removeParameter"
            name: "height"

Does this mean if no height is provided, we should remove height? I think maybe the if here should be height != '', to remove it if it is provided in the users code.
Although, this would also be incorrect since is it oneOf. That would mean the fix would apply only one if and then ignore the rest.

@kszczek
Copy link
Contributor Author

kszczek commented Feb 25, 2025

Hi, thanks for taking a look!

I think where you have 'null' in the fix yaml, it should be ''. In dart fix I don't think it will evaluate these arguments as null, they will just be blank.

Yes, when the height parameter is missing then it will be reported as blank.

Does this mean if no height is provided, we should remove height? I think maybe the if here should be height != '', to remove it if it is provided in the users code.
Although, this would also be incorrect since is it oneOf. That would mean the fix would apply only one if and then ignore the rest.

There are three scenarios in which we want to take action:

  1. if: "height == 'null'" - this condition is not meant to represent "if height was not provided", but rather "user explicitly placed a height: null parameter". This is quite unlikely though, as null is the default value anyway so setting it to null explicitly is basically a no-op, but in case someone has this dead code then let's clean up by simply removing it.

Now the ordering of those fixes is important, because if the first condition was not met, then in the remaining two conditionals we can assume that height is either not present or not null.

  1. if: "constraints == '' && height != ''" - constraints are not provided, but height is and we know it's not null. In this case we simply add constraints and remove height.
  2. if: "constraints == 'null' && height != ''" - user explicitly set constraints: null, and set some non-null height. In this case, we first remove the constraints: null, add constraints with the height's value, and remove height.

Let me know if I unnecessarily overcomplicated this fix 😄

@kszczek kszczek force-pushed the tooltip-constraints branch from 054c46f to 129ab89 Compare February 25, 2025 23:37
@kszczek
Copy link
Contributor Author

kszczek commented Feb 25, 2025

It turns out I forgot to mark the height parameter of the TooltipThemeData.copyWith as deprecated and that is the reason why dart fix wouldn't make the substitution.

This is now properly ready for review.

@kszczek
Copy link
Contributor Author

kszczek commented Feb 25, 2025

Also - a few of the existing tests use the height parameter. Should I refactor those tests in this PR along with the deprecation, or is this something that should be done when the parameter is going to be removed?

@kszczek kszczek force-pushed the tooltip-constraints branch 3 times, most recently from d66f209 to 9fb508b Compare February 26, 2025 09:53
@Piinks
Copy link
Contributor

Piinks commented Mar 5, 2025

Also - a few of the existing tests use the height parameter. Should I refactor those tests in this PR along with the deprecation, or is this something that should be done when the parameter is going to be removed?

No, having them in place during the deprecation period ensures we do not break anyone during the deprecation period. :)

@kszczek kszczek force-pushed the tooltip-constraints branch from 9fb508b to 6c6ac91 Compare March 5, 2025 22:52
Introduce a new `constraints` parameter, which constrains the size of
the tooltip's message and deprecate the now obsolete `height` parameter.
Do the same for the theme data, while also making some minor changes to
the docs to clear up some misconceptions about which properties apply
to the tooltip's message and which to the tooltip's child.

To make the transition from `height` to `constraints` as easy as
possible for our users, introduce fix data to do this replacement
automatically in the IDE.
@kszczek kszczek force-pushed the tooltip-constraints branch from 6c6ac91 to a8d0b7a Compare March 6, 2025 09:26
@dkwingsmt
Copy link
Contributor

@Piinks @chunhtai Seems like comments have been addressed. Can you take a look?

@chunhtai chunhtai self-requested a review March 12, 2025 18:58
Copy link
Contributor

@Piinks Piinks left a comment

Choose a reason for hiding this comment

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

This LGTM, thank you!

Copy link
Contributor

@gspencergoog gspencergoog left a comment

Choose a reason for hiding this comment

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

32384589-a60f0e74-c078-11e7-9bc1-e5b5287aea9d

@Piinks Piinks added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 17, 2025
@auto-submit auto-submit bot added this pull request to the merge queue Mar 17, 2025
Merged via the queue into flutter:master with commit 9d2b6da Mar 17, 2025
75 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Mar 17, 2025
@kszczek kszczek deleted the tooltip-constraints branch March 17, 2025 18:15
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: tech-debt Technical debt, code quality, testing, etc. d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tooltips should have customizable constraints
5 participants