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
fix(ng-update): hammer v9 migration should not unnecessarily set up gestures #17713
fix(ng-update): hammer v9 migration should not unnecessarily set up gestures #17713
Conversation
570cee9
to
5ef3483
Compare
Adding P1 label since this should go into the next possible RC. |
…estures We currently do not properly handle the scenario where a project uses a custom gesture config with event names matching the ones provided by the deprecated Angular Material gesture config. Prior to this commit, the migration would set up the Material gesture config next to the custom one. This is incorrect, and we should do nothing since a gesture config is already configured. Though, if we detect that there are manual references to the Angular Material gesture config, the detection is ambiguous and the migration should warn that the developer should manually remove the references to the deprecated Material gesture config. Also improves messaging for the migration, adds a description of the expected migration behavior into the migration rule and adds safety checks for `ts.Symbol#declaration` (should never be undefined according to typing, but for odd reasons it can be undefined, and we do not want to throw accidentally).
5ef3483
to
d8d7ea2
Compare
src/material/schematics/ng-update/upgrade-rules/hammer-gestures-v9/hammer-gestures-rule.ts
Outdated
Show resolved
Hide resolved
src/material/schematics/ng-update/upgrade-rules/hammer-gestures-v9/hammer-gestures-rule.ts
Outdated
Show resolved
Hide resolved
Address feedback
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
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.
Sorry for leaving some of the comments in the test instead of the code, but that's where I ran into the text first 😄
I think that we need to do more to avoid confusing and frustrating developers with this migration. I feel like we need a docs page for this migration similar to what angular.io has. There isn't enough actionable information in the current warnings and a docs page would allow us to provide that without having overly verbose ng update migration output.
src/material/schematics/ng-update/test-cases/v9/hammer-migration-v9.spec.ts
Show resolved
Hide resolved
src/material/schematics/ng-update/test-cases/v9/hammer-migration-v9.spec.ts
Show resolved
Hide resolved
expect(logOutput).toContain( | ||
'General notice: The HammerJS v9 migration for Angular components is not able to ' + | ||
'migrate tests. Please manually clean up tests in your project if they rely on the ' + | ||
'deprecated Angular Material gesture config.'); |
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.
Can we link them to the gesture config API or docs in case they haven't touched that part of their app in years or no one who set that up is still on the team?
If you Google "Angular Material gesture config", you mostly just see docs for Angular's HammerGestureConfig
and the Angular Material Getting Started Guide. So that won't be too helpful to them if we can't provide them some additional context/reference here.
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.
This message will be only printed if they explicitly reference the GestureConfig
from Angular Material. I think we can make the assumption that it is clear enough in that case.
I'm hesitant to adding any link since our docs page is likely to change in the future and we don't even have docs for material/core
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.
It would be nice to at least mention the GestureConfig
class explicitly in that case as some people may not immediately know that "gesture config" maps directly to that class.
src/material/schematics/ng-update/upgrade-rules/hammer-gestures-v9/hammer-gestures-rule.ts
Show resolved
Hide resolved
src/material/schematics/ng-update/upgrade-rules/hammer-gestures-v9/hammer-gestures-rule.ts
Show resolved
Hide resolved
src/material/schematics/ng-update/upgrade-rules/hammer-gestures-v9/hammer-gestures-rule.ts
Show resolved
Hide resolved
src/material/schematics/ng-update/upgrade-rules/hammer-gestures-v9/hammer-gestures-rule.ts
Show resolved
Hide resolved
src/material/schematics/ng-update/upgrade-rules/hammer-gestures-v9/hammer-gestures-rule.ts
Show resolved
Hide resolved
src/material/schematics/ng-update/upgrade-rules/hammer-gestures-v9/hammer-gestures-rule.ts
Show resolved
Hide resolved
'The HammerJS v9 migration for Angular components migrated the ' + | ||
'project to keep HammerJS installed, but detected ambiguous usage of HammerJS. Please ' + | ||
'manually check if you can remove HammerJS from your application.')); | ||
'manually check if you can remove HammerJS from your application.'); |
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.
Is there a docs page/section that we can point them to? How will they know if they can remove HammerJS from their app?
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.
Good question. I asked in Slack. Let's track that there.
Follow up feedback for the HammerJS v9 migration (based on comments by Michael in angular#17713)
Follow up feedback for the HammerJS v9 migration (based on comments by Michael in #17713)
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
We currently do not properly handle the scenario where a project
uses a custom gesture config with event names matching the ones
provided by the deprecated Angular Material gesture config.
Prior to this commit, the migration would set up the Material
gesture config next to the custom one. This is incorrect, and
we should do nothing since a gesture config is already configured.
Though, if we detect that there are manual references to the
Angular Material gesture config, the detection is ambiguous
and the migration should warn that the developer should manually
remove the references to the deprecated Material gesture config.
Also improves messaging for the migration, adds a description
of the expected migration behavior into the migration rule and
adds safety checks for
ts.Symbol#declaration
(should neverbe undefined according to typing, but for odd reasons it can be
undefined, and we do not want to throw accidentally).