Skip to content

Allow undefined & null values in [matTooltip] explicitly #29397

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

Merged
merged 4 commits into from
Jul 10, 2024

Conversation

Eyas
Copy link
Contributor

@Eyas Eyas commented Jul 8, 2024

We have tests that already set these values (but used to use nullness assertions to overcome the build failures) and protect against it by treating these values as empty strings (and thus we hide the tooltip), but we don't allow anyone who uses templates with strict type checking to set optional values unless they add their own nullness assertion.

@Eyas Eyas requested a review from a team as a code owner July 8, 2024 16:11
@Eyas Eyas requested review from amysorto and mmalerba and removed request for a team July 8, 2024 16:11
@mmalerba mmalerba self-assigned this Jul 8, 2024
Eyas and others added 4 commits July 8, 2024 13:11
… to use null/undefined types outright.

We were using nullness assertions to cause these assignments to succeed, but we should allow users to set null/undefined values outright.

Right now we don't, so this update will cause the tests to fail. But this will be soon fixed.
…ip]` explicitly.

We have tests that already set these values (but used to use nullness assertions to overcome the build failures) and protect against it by treating these values as empty strings (and thus we hide the tooltip), but we don't allow anyone who uses templates with strict type checking to set optional values unless they add their own nullness assertion.
….message` getter as always a string.

We do this since the underlying `._message` type is a string, the message setter can accept null and undefined values, but will convert them to strings before saving to `_message`, so we can always assume someone _reading_ the value will see a plain string.
@angular-robot angular-robot bot added the area: build & ci Related the build and CI infrastructure of the project label Jul 8, 2024
@mmalerba mmalerba added target: minor This PR is targeted for the next minor release action: merge The PR is ready for merge by the caretaker labels Jul 8, 2024
@mmalerba mmalerba removed the request for review from amysorto July 10, 2024 03:11
@mmalerba mmalerba merged commit 9401323 into angular:main Jul 10, 2024
26 of 28 checks passed
DBowen33 pushed a commit to DBowen33/components that referenced this pull request Jul 12, 2024
* fix(material/tooltip): Update MatTooltip's "message not present" test to use null/undefined types outright.

We were using nullness assertions to cause these assignments to succeed, but we should allow users to set null/undefined values outright.

Right now we don't, so this update will cause the tests to fail. But this will be soon fixed.

* fix(material/tooltip): Allow null and undefined values for `[matTooltip]` explicitly.

We have tests that already set these values (but used to use nullness assertions to overcome the build failures) and protect against it by treating these values as empty strings (and thus we hide the tooltip), but we don't allow anyone who uses templates with strict type checking to set optional values unless they add their own nullness assertion.

* fix(material/tooltip): Also explicitly define the type of `MatTooltip.message` getter as always a string.

We do this since the underlying `._message` type is a string, the message setter can accept null and undefined values, but will convert them to strings before saving to `_message`, so we can always assume someone _reading_ the value will see a plain string.

* ci: Approve new API goldens for tooltip

---------

Co-authored-by: Miles Malerba <[email protected]>
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Aug 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: build & ci Related the build and CI infrastructure of the project target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants