Skip to content

Better accessibility labels #105

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

Closed

Conversation

dflock
Copy link
Collaborator

@dflock dflock commented Jan 14, 2017

Starts to fix #74:

  • Associate each label with it's control, by making sure that each
    control has an id, and using the labels for attribute to bind
    to this.
  • Don't output label elements for button controls

I tried to keep the change set minimal, but some trailing white-space got removed.

Duncan Lock added 2 commits January 13, 2017 20:02
* Associate each label with it's control, by making sure that each
  control has an id, and using the labels `for` attribute to bind
  to this.
* Don't output label elements for button controls
@icebob
Copy link
Member

icebob commented Jan 14, 2017

Thanks, I will check it. Could you fix eslint errors?

@dflock
Copy link
Collaborator Author

dflock commented Jan 14, 2017

OK, eslint errors fixed, sorry about that - I normally use standard, so didn't run eslint 😊

@icebob
Copy link
Member

icebob commented Jan 14, 2017

No problem, thanks for fixing :)

@dflock
Copy link
Collaborator Author

dflock commented Jan 14, 2017

Just to be clear, this is merge-able, but not complete - not all inputs done and form level id prefix not done. Let me know what you think after testing and I'll update & complete.

@icebob
Copy link
Member

icebob commented Jan 16, 2017

I need more time, because I'm ill. 🤒

- Cleave
- DataTimePicker
- GoogleAddress
- Label
- Masked
- Select
- Spectrum
- Switch

Don't output labels for the following input types:

- button
- image
- submit
- reset
@dflock
Copy link
Collaborator Author

dflock commented Jan 17, 2017

Hope you feel better soon!

In the meantime, I've pushed support for a few more input types.

@icebob
Copy link
Member

icebob commented Jan 17, 2017

Thanks!

Great commit!

@icebob
Copy link
Member

icebob commented Jan 21, 2017

@dflock I checked commits. My suggestion is that, abstractField has reference to the schema as this.schema. So not neccessary to pass as parameter to getFieldID. And if no params, it can be a computed field as fieldID. What do you think?

	computed: {
		fieldID() {
			// Try to get a reasonable default id from the this.schema,
			// then slugify it.
			if (typeof this.schema.id !== "undefined") {
				// If an ID's been explicitly set, use it unchanged
				return this.schema.id;
			} else {
				return (this.schema.inputName || this.schema.label || this.schema.model)
				.toString()
				.trim()
				.toLowerCase()
				// Spaces to dashes
				.replace(/ /g, "-")
				// Multiple dashes to one
				.replace(/-{2,}/g, "-")
				// Remove leading & trailing dashes
				.replace(/^-+|-+$/g, "")
				// Remove anything that isn't a (English/ASCII) letter or number.
				.replace(/([^a-zA-Z0-9\._-]+)/g, "")
				;
			}
		}
	}

@icebob icebob closed this Feb 10, 2017
@dflock
Copy link
Collaborator Author

dflock commented Feb 10, 2017

Sorry, I've been up to my eyeballs lately and haven't had a chance to finish this off. I found some time to try your suggestion and it seemed to work OK in the components and abstractField.js, but not in formGenerator.vue. I didn't get chance to figure out why yet; I think this.schema means something different there?

Anyway, I'll try to get back to this as soon as I can - I'd really like to get this merged at some point - I haven't forgotten about it!

@icebob
Copy link
Member

icebob commented Feb 11, 2017

Thanks.
In this case, keep your getFieldID solution instead of my computed fields.

@dflock dflock mentioned this pull request Mar 22, 2017
@dflock
Copy link
Collaborator Author

dflock commented May 17, 2017

I'm back working on this again - sorry for the delay!

OK, I've pulled this branch up to date with current master.

Can you re-open this pull request, or do you want me to start a new one?

@icebob
Copy link
Member

icebob commented May 17, 2017

Hi,

I can't reopen because base branch (next) is deleted. You need to fork from master

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.

2 participants