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

Improved Angular compatibility #2229

Merged

Conversation

JBBianchi
Copy link
Contributor

@JBBianchi JBBianchi commented Dec 14, 2023

In the current stage, @jsonforms/angular-material still relies on @angular/flex-layout.

This package has been deprecated and isn't compatible with Angular v16+, therefore @jsonforms/angular-material would be stuck to Angular v15.

This PR removes the dependency to @angular/flex-layout by replacing the attributes with plain CSS instead.

Doing so, @jsonforms/angular-material becomes compatible with Angular v16 and v17 (at first sight).

For testing purposes, I forced upgrade the jsonforms-angular-seed projects to both v16 and v17:

I tried building the packages as submitted in this PR and running them in the above projects and it seems to work fine (it displays, I can remove one of the two items and I can update a text field. I didn't test more than that).

Related to

Copy link

netlify bot commented Dec 14, 2023

Deploy Preview for jsonforms-examples ready!

Name Link
🔨 Latest commit 44244a0
🔍 Latest deploy log https://app.netlify.com/sites/jsonforms-examples/deploys/65953e1ea605900007043ed4
😎 Deploy Preview https://deploy-preview-2229--jsonforms-examples.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@JBBianchi
Copy link
Contributor Author

(Follow up of #2212)

@JBBianchi
Copy link
Contributor Author

JBBianchi commented Dec 14, 2023

I might have messed up the pnpm-lock.yaml ...

Is there a way for pnpm to use Angular v15 even if the package is compatible with higher versions ? (compile vs usage)

Edit: I went with pnpm.overrides

@gexclaude
Copy link

@JBBianchi really appreciate your efforts!

@coveralls
Copy link

coveralls commented Dec 15, 2023

Coverage Status

coverage: 83.078%. remained the same
when pulling 44244a0 on JBBianchi:angular-v15-no-flex-layout
into a7d3268 on eclipsesource:master.

@JBBianchi
Copy link
Contributor Author

JBBianchi commented Dec 15, 2023

We could actually use Angular v16 for the build process, which will allow to be compliant with #2224 .

Should I add this to this PR as well ? It's basically just changing the pnpm.overrides and removing the entryComponents config from the tests so the impact is pretty low.

@sdirix @lucas-koehler WDYT ?

Edit: FYI, in the meanwhile, I pushed those changes to https://github.com/JBBianchi/jsonforms/tree/angular-v16 so you can compare both branches. (the pipeline runs successfully https://github.com/JBBianchi/jsonforms/actions/runs/7220751941 )

@lucas-koehler
Copy link
Contributor

Hi @JBBianchi,
first of all thanks for the PR and your continued effort on improving the angular renderer set ❤️
I see no harm in using Angular 16 for the build process already. So gladly go ahead with that :)

@JBBianchi
Copy link
Contributor Author

JBBianchi commented Dec 15, 2023

Hi @JBBianchi, first of all thanks for the PR and your continued effort on improving the angular renderer set ❤️ I see no harm in using Angular 16 for the build process already. So gladly go ahead with that :)

For ng16, I'll hold my horses because the example doesn't seem to run. I'll need to investigate a bit more even though all lights seemed green at first.

Edit: For the record, I have no idea why but there is a "glitch" in the rollup output of the example with Angular 16. In @angular/core, a QueryList is declared as:

class QueryList {
    static { Symbol.iterator; }
    /**
     * Returns `Observable` of `QueryList` notifying the subscriber of changes.
     */
    get changes() {
        return this._changes || (this._changes = new EventEmitter());
    }
...

But in the rollup output, the static bit is messed up:

class QueryList {
    s }
    /**
    * Returns `Observable` of `QueryList` notifying the subscriber of changes.
    */
    get changes() {
        return this._changes || (this._changes = new EventEmitter());
    }
...

Edit 2: the fix was simply to update rollup, I should have thought about that faster.

@JBBianchi
Copy link
Contributor Author

@lucas-koehler @sdirix the PR should be ready for review.

Copy link
Contributor

@lucas-koehler lucas-koehler left a comment

Choose a reason for hiding this comment

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

Hi thanks again for the PR ❤️
The changes already look pretty good to me :)
I have some minor comments/questions inline.

packages/angular-material/src/controls/range.renderer.ts Outdated Show resolved Hide resolved
packages/angular-material/test/group-layout.spec.ts Outdated Show resolved Hide resolved
packages/angular-material/test/horizontal-layout.spec.ts Outdated Show resolved Hide resolved
packages/angular-material/tsconfig.spec.json Outdated Show resolved Hide resolved
- readded angularCompilerOptions in tests tsconfig
- removed empty imports array in tests
- applied flex to divs only in group-layout renderer
- removed html comment in range renderer
Copy link
Contributor

@lucas-koehler lucas-koehler left a comment

Choose a reason for hiding this comment

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

Hi the code changes LGTM. I had a look at the example. It looked pretty good to me. I only noticed that the group layout is now a bit cramped due to missing padding.

@lucas-koehler
Copy link
Contributor

@JBBianchi Thanks for the update. Do you know whether the code will still work for Angular 15 when it's built with Angular 16 ?
If yes that's fine for me :) Otherwise, we can also remove compatibility to Angular 15.

Copy link
Contributor

@lucas-koehler lucas-koehler left a comment

Choose a reason for hiding this comment

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

In the seed, I tested the changes with 15, 16 and 17. The seed did not compile with 15 but worked with 16 and 17. Thus, I suggest removing compatibility to 15. It is end of life in less than half a year anyway.

Also I noticed another bug, the packages/angular-material/src/controls/range.renderer.ts does no longer have functioning data binding. I think this might already have been introduced with the Angular 15 support PR when the value and onChange properties were removed in packages/angular-material/src/controls/range.renderer.ts

@JBBianchi
Copy link
Contributor Author

In the seed, I tested the changes with 15, 16 and 17. The seed did not compile with 15 but worked with 16 and 17. Thus, I suggest removing compatibility to 15. It is end of life in less than half a year anyway.

Also I noticed another bug, the packages/angular-material/src/controls/range.renderer.ts does no longer have functioning data binding. I think this might already have been introduced with the Angular 15 support PR when the value and onChange properties were removed in packages/angular-material/src/controls/range.renderer.ts

Thanks for testing in the seed v15, that's unfortunate but indeed, support could be dropped.

I'll try to have look during next week if I have some time.

@JBBianchi
Copy link
Contributor Author

It seems indeed that a library built with ng 16 is not compatible with ng 15 because the signature of the @Input() directive changed.

For the range control, the binding of the change event was "cleaned out" by mistake in this commit.

Next commit will remove compatibility with ng 15 and rebind a the event to the range control.

Copy link
Contributor

@lucas-koehler lucas-koehler left a comment

Choose a reason for hiding this comment

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

Hi @JBBianchi thanks for the updates :) Changes look pretty good to me now. I have just one question regarding the pnpm overrides inline.
I also updated the lock file.

package.json Outdated
Comment on lines 53 to 73
"overrides": {
"@angular/animations": "^16.0.0",
"@angular/cdk": "^16.0.0",
"@angular/common": "^16.0.0",
"@angular/core": "^16.0.0",
"@angular/forms": "^16.0.0",
"@angular/material": "^16.0.0",
"@angular/platform-browser": "^16.0.0",
"@angular/router": "^16.0.0",
"@angular-devkit/build-angular": "^16.0.0",
"@angular-eslint/eslint-plugin": "^16.0.0",
"@angular-eslint/eslint-plugin-template": "^16.0.0",
"@angular-eslint/schematics": "^16.0.0",
"@angular-eslint/template-parser": "^16.0.0",
"@angular/compiler": "^16.0.0",
"@angular/compiler-cli": "^16.0.0",
"@angular/platform-browser-dynamic": "^16.0.0",
"@ngtools/webpack": "^16.0.0",
"ng-packagr": "^16.0.0",
"zone.js": "^0.13.0"
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we still need these overrides now that we removed Angular 15 compatibility?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not 100% sure. If I'm not mistaken, as the packages declare a compatibility with Angular 16 and 17 (and maybe 18 in the future), pnpm will install the highest version compatible by default, so v17. So we need the overrides to say "build with v16 even if the lib is compatible with v17".

Copy link
Member

@sdirix sdirix Jan 2, 2024

Choose a reason for hiding this comment

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

Can we use Angular 16 in the devDependencies and not 16 || 17? As we don't bundle Angular the peerDependencies version is the important one for the consumer and could still be 16 || 17 even if the devDependencies only declare 16.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sdirix thanks for your input, that's better indeed.

lucas-koehler and others added 3 commits January 2, 2024 10:57
Update the pnpm lock file and override vue and @vue/compiler-sfc dependencies to ~3.3.13 because vue-vanilla tests currently fail when updating to vue 3.4.x.
Copy link
Contributor

@lucas-koehler lucas-koehler left a comment

Choose a reason for hiding this comment

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

Hi @JBBianchi , the PR looks good to me now. I updated all dependencies and added overrides for vue because its latest version doesn't work. I added issue #2234 to fix this later.

Thanks again for your effort on the Angular packages ❤️

@lucas-koehler lucas-koehler merged commit c2836a5 into eclipsesource:master Jan 3, 2024
8 checks passed
@sdirix sdirix linked an issue Jan 30, 2024 that may be closed by this pull request
@@ -140,9 +143,6 @@ export const removeSchemaKeywords = (path: string) => {
top: 0;
right: 0;
}
.hide {
display: none;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this deleted?

Copy link
Contributor Author

@JBBianchi JBBianchi Apr 29, 2024

Choose a reason for hiding this comment

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

It might be an error when factoring out @angular/flex-layout with [ngStyle]="{ display: hidden ? 'none' : '' }" instead of [fxHide]="hidden". Do you encounter any problem ?

Edit:
It is mistake indeed. The delete button should be displayed only when an item is hovered and hidden (via the hide class) by default. Removing the hide class made the delete button always visible.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah right, that's why I am writing. The delete button is always shown. We created a custom listWithDetail renderer to counter this problem. Is there a better solution? Or can you restore the deleted CSS class?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not a maintainer of this repo but I'd assume you can open an issue explaining the problem and them submit a PR to solve it. Then maintainers can maybe accept the PR and push it in the next release.

Copy link
Member

Choose a reason for hiding this comment

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

Happy to review and merge a PR

Copy link
Contributor

Choose a reason for hiding this comment

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

I've created the issue: #2327
Should you give me permission in order to open a MR?

Copy link
Contributor

Choose a reason for hiding this comment

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

@stanisev Thanks for creating the issue :) You can gladly open a MR anytime you want.

Copy link
Contributor

Choose a reason for hiding this comment

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

@lucas-koehler It seems that I cannot create branch/open MR, can you please help me it seems to be permission issue

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @stanisev , did you try to push the branch directly to this repository? This is not possible because you do not have write permissions. You need to fork the repository and push the branch to your fork. Then, you should be able to open a MR against this repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Angular w/ Material v16
6 participants