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

Checkbox field id has dash appended #421

Closed
hughbris opened this issue May 11, 2020 · 3 comments
Closed

Checkbox field id has dash appended #421

hughbris opened this issue May 11, 2020 · 3 comments

Comments

@hughbris
Copy link
Contributor

I set the id property for a checkbox field in frontmatter, The field is being output with '-' appended to that id string. (Makes it difficult to select using JS DOM methods, affects label accessibility, etc.)

Looks like the checkbox template includes reference to a key Twig variable. Couldn't figure out where it's meant to be coming from, but it's empty in my case.

My guess is that that line

{% set id = field.id|default(field.name) ~ '-' ~ key %}

should be

{% set id = field.id|default(field.name ~ '-' ~ key) %}

or

{% set id = field.id|default(field.name) ~ (key ? '-' ~ key) %}

depending on what the intent and context is here. If you advise me, I'll make a PR.

Not sure if other field types are affected.

@hughbris hughbris changed the title Getting hiphen after checkbox field id Checkbox field id has dash appended May 11, 2020
@rhukster
Copy link
Member

I think this one: {% set id = field.id|default(field.name ~ '-' ~ key) %} is the intended approach. although key should be in index of the looping over the elements.. this is to ensure they are unique. let me take a look...

@rhukster
Copy link
Member

Ok, i see what happened here. We added the key logic to checkboxes and it was copied to checkbox which is the singular variation. I've removed the -key logic completely for next release in this case.

rhukster added a commit that referenced this issue May 13, 2020
@hughbris
Copy link
Contributor Author

hughbris commented Dec 3, 2020

Fixed by eea1e45, cross referencing and closing.

@hughbris hughbris closed this as completed Dec 3, 2020
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

No branches or pull requests

2 participants