Skip to content

Angular Material: OneOf Enum Control Renderer#2551

Merged
sdirix merged 5 commits into
eclipsesource:masterfrom
daniel-shuy:angular-material/oneof-enum-control-renderer
May 4, 2026
Merged

Angular Material: OneOf Enum Control Renderer#2551
sdirix merged 5 commits into
eclipsesource:masterfrom
daniel-shuy:angular-material/oneof-enum-control-renderer

Conversation

@daniel-shuy

@daniel-shuy daniel-shuy commented Mar 2, 2026

Copy link
Copy Markdown
Contributor

Renamed AutocompleteControlRenderer to EnumControlRenderer to be consistent with other renderer sets

  • For backwards compatibility, I've retained the old component selector and exported the component with the old class name as an alias

The OneOfEnumControlRenderer has the same implementation as the EnumControlRenderer, the only difference being that it takes in EnumOption[] instead of string[], so that a different label can be displayed instead of the value:

export interface EnumOption {
label: string;
value: any;
}

  • oneOf.const is mapped to EnumOption.value
  • oneOf.title is mapped to EnumOption.label

@netlify

netlify Bot commented Mar 2, 2026

Copy link
Copy Markdown

Deploy Preview for jsonforms-examples ready!

Name Link
🔨 Latest commit bed6dd0
🔍 Latest deploy log https://app.netlify.com/projects/jsonforms-examples/deploys/69b7a94ca2e94f000791f6f1
😎 Deploy Preview https://deploy-preview-2551--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 project configuration.

@sdirix sdirix left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for your contribution! ❤️

Comment thread packages/angular-material/src/library/controls/one-of-enum.renderer.ts Outdated
@daniel-shuy
daniel-shuy force-pushed the angular-material/oneof-enum-control-renderer branch from 3f7d65d to e94da20 Compare March 10, 2026 04:13
@daniel-shuy
daniel-shuy requested a review from sdirix March 10, 2026 04:19
@daniel-shuy
daniel-shuy force-pushed the angular-material/oneof-enum-control-renderer branch from e94da20 to fc55e41 Compare March 12, 2026 03:57
@daniel-shuy

daniel-shuy commented Mar 12, 2026

Copy link
Copy Markdown
Contributor Author

The modification of the .eslintrc.js (to lint Angular templates in .html files) has caused previously unresolved ESLint violations to resurface, causing the build to fail. I've resolved them in this PR.

@daniel-shuy
daniel-shuy force-pushed the angular-material/oneof-enum-control-renderer branch from fc55e41 to bf1d6ed Compare March 12, 2026 07:30
Comment thread packages/angular-material/.eslintrc.js
@coveralls

coveralls commented Mar 12, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 82.854% (+0.002%) from 82.852%
when pulling bed6dd0 on daniel-shuy:angular-material/oneof-enum-control-renderer
into fd7979a on eclipsesource:master.

Comment thread packages/angular-material/src/library/controls/enum.renderer.ts Outdated
@daniel-shuy
daniel-shuy requested a review from sdirix March 16, 2026 06:57
@daniel-shuy

Copy link
Copy Markdown
Contributor Author

Hi @sdirix, any update?

@sdirix sdirix left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good, but I saw a minor issue.

Comment on lines +239 to +249
export class EnumControlRenderer extends OneOfEnumControlRenderer {
// eslint-disable-next-line @angular-eslint/no-input-rename
@Input('options')
set stringOptions(strOptions: string[]) {
this.options = strOptions.map((str) => {
return {
label: str,
value: str,
};
});
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The old AutocompleteControlRenderer accepted EnumOption[] | string[] via @Input. This setter only handles string[]. If someone has <AutocompleteControlRenderer [options]="enumOptionArray">, the setter will silently produce garbage.

We should remove the old component completely so they get an obvious error or make it backward compatible. If we remove it, we should mention it in the migration guide

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Actually, the @Input was previously changed by me in a previous PR (#2535) from string[] to EnumOption[] | string[] so that users can pass in options with different labels from their values to the AutocompleteControlRenderer. I reverted that change since the new OneOfEnumControlRenderer should be used for that purpose instead.

Since #2535 is not part of any release, the @Input type can be safely reverted back to string[].

@sdirix
sdirix merged commit 154369e into eclipsesource:master May 4, 2026
8 checks passed
@lucas-koehler lucas-koehler added this to the 3.8 milestone Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants