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

Radio buttons where there are multiple keys chosen show the first one alphabetically as selected #8796

Closed
peternewman opened this issue Nov 8, 2021 · 2 comments
Labels
field An issue with a field in the user interface

Comments

@peternewman
Copy link
Contributor

peternewman commented Nov 8, 2021

URL

https://www.openstreetmap.org/way/423881224

How to reproduce the issue?

Look at an object which has some form of radio button interface implemented via multiple keys, which appears to currently be just these two fields:
https://github.com/openstreetmap/id-tagging-schema/blob/bde8a416c80cbbb27a0ad36df3c6dcec3151ec8b/dist/fields.json#L2805-L2812
https://github.com/openstreetmap/id-tagging-schema/blob/bde8a416c80cbbb27a0ad36df3c6dcec3151ec8b/dist/fields.json#L1083-L1095

I know the second one has been somewhat divisive:
https://github.com/openstreetmap/iD/issues?q=is%3Aissue+toilet

So without wishing to re-open those debates, given a radio button is currently used to render these (and hence you can't select more than one choice), wouldn't it be better if no option was selected on the radio when more than one was chosen (so the blue highlighting was more obvious).

Logically I could imagine the second existing and indeed a bit of Overpass searching found some fords in tunnels, so they're both real world scenarios.

Example node:
Structure: https://www.openstreetmap.org/way/423881224
Toilet: https://www.openstreetmap.org/node/411286195

Screenshot(s) or anything else?

Structure:
image
image

Toilets:
image
image

Which iD Editor versions do you see the issue on?

Released version at openstreetmap.org/edit

Which browsers are you seeing this problem on?

Firefox

@1ec5
Copy link
Collaborator

1ec5 commented Nov 8, 2021

I think what you’re seeing is that the field checks the radio button that comes last visually, not first alphabetically. The radio buttons have the same name attribute, so the browser only allows one to be checked at a time, but this code checks each applicable radio button in order, regardless of the other radio buttons. That causes the browser to uncheck all the previously checked radio buttons:

radios.property('checked', function(d) {
if (field.key) {
return tags[field.key] === d;
}
return !!(typeof tags[d] === 'string' && tags[d].toLowerCase() !== 'no');
});

The blue highlighting for multiple selection is subtle indeed. I wonder if that’s a side effect of implementing simultaneous editing of multiple features in #7306. It looks slightly different when selecting two features with different values for the same key, but none of the radio buttons is checked, which is good:

toilets

@tyrasd tyrasd added the field An issue with a field in the user interface label Nov 9, 2021
@tyrasd tyrasd closed this as completed in f3e8852 Nov 9, 2021
@peternewman
Copy link
Contributor Author

I think what you’re seeing is that the field checks the radio button that comes last visually, not first alphabetically.

Well spotted @1ec5 , I clearly hadn't tested well enough and just made assumptions.

Thanks for fixing it @tyrasd !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
field An issue with a field in the user interface
Projects
None yet
Development

No branches or pull requests

3 participants