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

fix: enable using custom id for form-item label #3701

Merged
merged 1 commit into from
Apr 20, 2022

Conversation

tomivirkki
Copy link
Member

Fixes #3682

@tomivirkki tomivirkki requested a review from vursen April 19, 2022 09:52
@sonarcloud
Copy link

sonarcloud bot commented Apr 19, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

this.__labelId = this.__labelNode.id;
} else {
// The new label node doesn't have an id yet. Generate a unique one.
const uniqueId = (FormItem._uniqueLabelId = 1 + FormItem._uniqueLabelId || 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we generate a unique id only once in the constructor?

Copy link
Member Author

@tomivirkki tomivirkki Apr 19, 2022

Choose a reason for hiding this comment

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

I did consider it but maybe it's cleaner to identify individual <label> instances with separate IDs? Sharing the same ID would require us to remove the id from a <label> element when removed/replaced with a new label, and a custom ID would need to be an exception since it should not be removed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, right, this is reasonable. 👍

@tomivirkki tomivirkki merged commit 124a333 into master Apr 20, 2022
@tomivirkki tomivirkki deleted the form-item-label-custom-id branch April 20, 2022 05:59
tomivirkki added a commit that referenced this pull request Apr 20, 2022
Co-authored-by: Tomi Virkki <tomivirkki@users.noreply.github.com>
@vaadin-bot
Copy link
Collaborator

This ticket/PR has been released with Vaadin 23.1.0.alpha3 and is also targeting the upcoming stable 23.1.0 version.

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.

User defined id gets overwritten
3 participants