Skip to content

Commit

Permalink
Merge 02231fd into 066a697
Browse files Browse the repository at this point in the history
  • Loading branch information
manolo committed Aug 16, 2018
2 parents 066a697 + 02231fd commit 2576bf8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/vaadin-radio-group.html
Expand Up @@ -206,7 +206,9 @@

this.setAttribute('role', 'radiogroup');

this.addEventListener('focusout', e => this.validate());
// Need to check e.composed as a workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=1472887
// otherwise FF runs validation on keyboard focus
this.addEventListener('focusout', e => e.composed && this.validate());

const uniqueId = RadioGroupElement._uniqueId = 1 + RadioGroupElement._uniqueId || 0;
this._errorId = `${this.constructor.is}-error-${uniqueId}`;
Expand Down
10 changes: 8 additions & 2 deletions test/vaadin-radio-group.html
Expand Up @@ -61,8 +61,8 @@
<script>
describe('vaadin-radio-group', () => {

function blur(e) {
e.dispatchEvent(new CustomEvent('focusout', {bubbles: true, composed: true}));
function blur(e, composed = true) {
e.dispatchEvent(new CustomEvent('focusout', {bubbles: true, composed: composed}));
}

function visible(e) {
Expand Down Expand Up @@ -335,6 +335,12 @@
expect(vaadinRadioButtonGroup.invalid).to.be.true;
});

it('should not run validation if focusout is not composed', () => {
vaadinRadioButtonGroup.required = true;
blur(vaadinRadioButtonGroup, false);
expect(vaadinRadioButtonGroup.invalid).to.be.false;
});

it('error should have appropriate aria attributes and id', () => {
expect(errorElement.getAttribute('aria-live')).to.be.equal('assertive');
expect(errorElement.getAttribute('aria-hidden')).to.be.equal('true');
Expand Down

0 comments on commit 2576bf8

Please sign in to comment.