Skip to content

Better accessibility labels - to master #201

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

Merged
merged 10 commits into from
May 24, 2017

Conversation

dflock
Copy link
Collaborator

@dflock dflock commented May 18, 2017

Same as #105, but onto the master branch, instead of the old next branch.

Duncan Lock and others added 7 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
- Cleave
- DataTimePicker
- GoogleAddress
- Label
- Masked
- Select
- Spectrum
- Switch

Don't output labels for the following input types:

- button
- image
- submit
- reset
@icebob
Copy link
Member

icebob commented May 19, 2017

@dflock Thank you. Nice PR! Could you add test for abstractField.getFieldID ?

Added some tests for the getFieldID function - and tightened up it's slugification.

- Tests that values are correctly slugified
- Tests that schema properties are returned in the expected order of preference
@dflock
Copy link
Collaborator Author

dflock commented May 23, 2017

Was trying to add a test to vue-form-generator/test/unit/specs/VueFormGenerator.spec.js to test the fieldTypeHasLabel function, but I couldn't figure out how to call that function from the test?

@dflock
Copy link
Collaborator Author

dflock commented May 23, 2017

I should probably update the docs, too. How do I submit a pull request for this page?

@icebob
Copy link
Member

icebob commented May 23, 2017

For fieldTypeHasLabel create a simple describe block:

describe("check fieldTypeHasLabel function", () => {
	before( () => {
		createFormGenerator({ fields: [] }, {});
	});

	it("should return true", () => {
		expect(vm.fieldTypeHasLabel({ type: "input", inputType: "checkbox"})).to.be.true;
		expect(vm.fieldTypeHasLabel({ type: "input", inputType: "text"})).to.be.true;
	});	

	it("should return false", () => {
		expect(vm.fieldTypeHasLabel({ type: "input", inputType: "button"})).to.be.false;
		expect(vm.fieldTypeHasLabel({ type: "checklist" })).to.be.false;
	});	
});

The code is just a sketch, not guaranteed it is working.

To update docs, you need to register on gitbook and send me your username.

Test not yet working, commiting to share.
@dflock
Copy link
Collaborator Author

dflock commented May 23, 2017

That (and variants) are basically what I tried - but I couldn't figure out how to actually call the fieldTypeHasLabel function successfully. If I copy your code and run the tests I get this:

check fieldTypeHasLabel function
  ✗ should return true
undefined is not a function (evaluating 'vm.fieldTypeHasLabel({ type: "input", inputType: "checkbox" })')

So maybe the vm object doesn't have a fieldTypeHasLabel method at that point?

If I add a console.log(vm) in there, it prints out a load of this kind of stuff:

..., _vnode: ..., _staticTrees: ..., $slots: ..., $scopedSlots: ..., _c: ..., $createElement: ..., _watchers: ..., disabled: ..., schema: ..., model: ..., options: ..., multiple: ..., isNewModel: ..., tag: ..., validate: ..., clearValidationErrors: ..., setModelValueByPath: ..., getFieldID: ..., getFieldRowClasses: ..., getFieldType: ..., fieldTypeHasLabel: ..., fieldDisabled: ..., fieldRequired: ..., fieldVisible: ..., fieldReadonly: ..., fieldFeatured: ..., buttonClickHandler: ..., onFieldValidated: ..., modelUpdated: ..., buttonVisibility: ..., fieldErrors: ..., _data: ..., errors: ..., value: ..., fields: ..., $el: ...}], $refs: Object{form: VueComponent{_uid: ..., _isVue: ..., $options: ..., _renderProxy: ..., _self: ..., $parent: ..., $root: ..., $children: ..., $refs: ..., _watcher: ..., _inactive: ..., _isMoun

which does include , fieldTypeHasLabel: a couple of times. I've not written node/karma unit tests before, so I'm not sure the best way to debug what's going on in the tests?

I've added the code for this test to the branch so you can try it out if you like.

@dflock
Copy link
Collaborator Author

dflock commented May 23, 2017

Also, my gitbooks username is dflock.

@icebob
Copy link
Member

icebob commented May 23, 2017

I was wrong becase vm is the parent and not the vfg instance.
Change the test to it:

	describe("check fieldTypeHasLabel function", () => {
		let form;
		before( () => {
			createFormGenerator({ fields: [] }, {});
			form = vm.$refs.form;
		});

		it("should return true", () => {
			expect(form.fieldTypeHasLabel({ type: "input", inputType: "checkbox"})).to.be.true;
			expect(form.fieldTypeHasLabel({ type: "input", inputType: "text"})).to.be.true;
			expect(form.fieldTypeHasLabel({ type: "checklist" })).to.be.true;
		});

		it("should return false", () => {
			expect(form.fieldTypeHasLabel({ type: "input", inputType: "button"})).to.be.false;
			expect(form.fieldTypeHasLabel({ type: "input", inputType: "image"})).to.be.false;
			expect(form.fieldTypeHasLabel({ type: "input", inputType: "submit"})).to.be.false;
			expect(form.fieldTypeHasLabel({ type: "input", inputType: "reset"})).to.be.false;
		});
	});

@dflock
Copy link
Collaborator Author

dflock commented May 23, 2017

Thanks! Test fixed and pushed. Will work on docs now.

@dflock
Copy link
Collaborator Author

dflock commented May 24, 2017

@icebob icebob merged commit 5552079 into vue-generators:master May 24, 2017
@icebob
Copy link
Member

icebob commented May 24, 2017

Thank you. Nice PR! Merged.

@dflock dflock deleted the better-accessibility-labels branch May 24, 2017 19:26
@icebob icebob mentioned this pull request May 25, 2017
@icebob
Copy link
Member

icebob commented May 31, 2017

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.

3 participants