-
Notifications
You must be signed in to change notification settings - Fork 20
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(tegel-angular): reactive forms integration #598
feat(tegel-angular): reactive forms integration #598
Conversation
@theJohnnyMe @timrombergjakobsson Would it be possible to publish beta testing packages of this change so it would be easier to test locally? At the moment both packages need to be generated locally, which is a bit of a hassle. |
This pull request is automatically being deployed by Amplify Hosting (learn more). |
For sure, that would not be a problem, I will ping you once we do so. Thanks a lot for your contribution @adarean5 ! 🚀 |
41a6253
to
3b1cbd6
Compare
Amazing, thank you! I have tested the changes in the tegel-angular-demo project, but I cannot push my branch, since I'm not a contributor on that project. Would it be possible to make me a contributor there as well? I could update the demo app myself once these changes are a part of the official Tegel package. |
Invite sent ;) |
Wow! Thanks for your contribution @adarean5! |
Looks like there are some issues with checkboxes integration at the moment. I will need to look into it. |
3b1cbd6
to
0248380
Compare
I added support for checkboxes and chips. I also added a chip example to the angular demo project. I'm not sure what's the proper way to set up chips in the I was also unable to get the radio buttons to work natively. The issue is that the radio buttons are not really a single control, but multiple controls. Perhaps at some point the radio buttons can be reworked to offer a single parent control, to which you can bind values. I think that would be more practical. For now angular forms integration won't be implemented for the radio buttons. |
This is the branch for the angular demo app: /~https://github.com/scania-digital-design-system/tegel-angular-demo/tree/feat/angular-forms-updates I was able to simplify the forms implementation quite a bit due to these changes! |
@adarean5 - both @scania/tegel and @scania/tegel-angular are now having new beta release with 1.8.0-ng-form-beta.1 as version. |
I tested the new package with my project and also the Tegel angular demo project. |
Hi @adarean5! Great stuff! For projects that have implemented their own value accessors ,the migration path involves removing these custom value accessors. I guess this should be a straightforward process but requires testing to ensure that removing these does not introduce new issues. Since this change might affect several projects, probably would be advisable to engage with the community of developers using tegel-angular to gather feedback, provide support, and address any concerns they might have? |
It should be straightforward to migrate, but it's nearly impossible to predict what solutions various projects came up with for handling the integration. I've tested the changes on my project and the Tegel demo project and haven't experienced any difficulties. I'm still waiting for a few teams from other projects to test the demo package, but it seems like the testing of this change hasn't been prioritized by those teams. Not sure how much longer we should wait, since many projects would benefit from this change. |
I did some more investigation into the way the Stencil angular plugin handles radio buttons. There might be a bug in their value accessor. I reported it to Stencil, but they don't seem to prioritize issues regarding the angular integration. In the mean time, I will try to create a custom value accessor that extends the base ValueAccessor in a way that is more similar to the way angular handles native radio inputs. |
I managed to add support for the two remaining inputs:
when in radio mode, tds-chip uses the same value accessor as tds-radio-button, since they behave identically. @theJohnnyMe @timrombergjakobsson @nathalielindqvist would it be possible to update the beta package with these changes? |
@adarean5 - I will do another beta release today and I will ping you once it is out ;) |
@adarean5 - 1.8.0-ng-form-beta.2 is out! ;) |
Quality Gate passedIssues Measures |
packages/angular-17/projects/components/src/lib/directives/tds-dropdown-value-accessor.ts
Show resolved
Hide resolved
@theJohnnyMe I think that the changes you made look good. The build output seems correct and is copied to the angular and angular-17 projects. The best way to test this would be to create a fresh angular 18 project (esbuld by default now), create a component with FormGroup and bind form controls to the tegel inputs without using |
b73ee52
to
9b7316d
Compare
Quality Gate passedIssues Measures |
9b7316d
to
7465222
Compare
7465222
to
01ac591
Compare
I have opened PR to test code on Angular Demo page here: scania-digital-design-system/tegel-angular-demo#99 It is Jernej's branch, but updated with latest package. |
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.
Amazing work Jernej, truly!
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.
Awesome stuff!
01ac591
to
50007c5
Compare
Quality Gate passedIssues Measures |
Describe pull-request
Adds native integration with the angular reactive forms for the Tegel input components.
Solving issue
Fixes: #546
How to test
This one is a bit tricky to test locally since it requires packages to be packed locally first.
packages/core
packages
directory in your home foldernpm run build
npm pack --pack-destination ~/packages
- This should create$homeFolder/packages/scania-tegel-1.8.0.tgz
npm run build
inside packages/angularnpm pack --pack-destination ~/packages
inside packages/angular@scania/tegel-angular
package to"@scania/tegel-angular": "file:~/packages/scania-tegel-angular-1.8.0.tgz"
ngDefaultControl
directives from your inputs.Checklist before submission
Suggested test steps
Screenshots
Additional context
The existing
angularValueAccessorBindings
configuration inside stencil.config.ts was mostly correct, but it was not applied, since the generated value accessors weren't exported from theTegelModule
. The value accessors are now exported.tds-dropdown
did not work with the auto-generated value accessors out of the box, so I needed to implement an "adapter" value accessor (packages/angular/projects/components/src/lib/directives/tds-dropdown-value-accessor.ts)The
handleInput
event intds-text-field
andtds-textarea
was emitting the event before updating its value. This caused issues when binding to tdsInput, sinceevent.target.value
was the previous value and not the current value. I fixed this by changing the order inside the method from:To:
Forms integration has been implemented for the following components: