@lion/choice-input
Advanced tools
Comparing version 0.7.6 to 0.7.7
@@ -6,2 +6,13 @@ # Change Log | ||
## [0.7.7](https://github.com/ing-bank/lion/compare/@lion/choice-input@0.7.6...@lion/choice-input@0.7.7) (2020-03-19) | ||
### Bug Fixes | ||
* normalization model-value-changed events ([1b6c3a4](https://github.com/ing-bank/lion/commit/1b6c3a44c820b9d61c26849b91bbb1bc8d6c772b)) | ||
## [0.7.6](https://github.com/ing-bank/lion/compare/@lion/choice-input@0.7.5...@lion/choice-input@0.7.6) (2020-03-12) | ||
@@ -8,0 +19,0 @@ |
{ | ||
"name": "@lion/choice-input", | ||
"version": "0.7.6", | ||
"version": "0.7.7", | ||
"description": "Base for all choise inputs like checkbox/radio", | ||
@@ -38,7 +38,7 @@ "author": "ing-bank", | ||
"@lion/core": "0.4.5", | ||
"@lion/field": "0.11.3" | ||
"@lion/field": "0.11.4" | ||
}, | ||
"devDependencies": { | ||
"@lion/fieldset": "0.9.3", | ||
"@lion/input": "0.5.18", | ||
"@lion/fieldset": "0.9.4", | ||
"@lion/input": "0.5.19", | ||
"@lion/validate": "0.8.0", | ||
@@ -49,3 +49,3 @@ "@open-wc/demoing-storybook": "^1.10.4", | ||
}, | ||
"gitHead": "af03fd41b05efece395518b1ae938cad56f247f1" | ||
"gitHead": "f286e3ac28fe0b34284383344fda4dc8e9ea593d" | ||
} |
@@ -58,18 +58,5 @@ import { dedupeMixin } from '@lion/core'; | ||
this.multipleChoice = false; | ||
this._repropagationRole = 'choice-group'; // configures event propagation logic of FormControlMixin | ||
} | ||
connectedCallback() { | ||
super.connectedCallback(); | ||
if (!this.multipleChoice) { | ||
this.addEventListener('model-value-changed', this._checkSingleChoiceElements); | ||
} | ||
} | ||
disconnectedCallback() { | ||
super.disconnectedCallback(); | ||
if (!this.multipleChoice) { | ||
this.removeEventListener('model-value-changed', this._checkSingleChoiceElements); | ||
} | ||
} | ||
/** | ||
@@ -161,5 +148,6 @@ * @override from FormRegistrarMixin | ||
__triggerCheckedValueChanged() { | ||
__setChoiceGroupTouched() { | ||
const value = this.modelValue; | ||
if (value != null && value !== this.__previousCheckedValue) { | ||
// TODO: what happens here exactly? Needs to be based on user interaction (?) | ||
this.touched = true; | ||
@@ -184,3 +172,22 @@ this.__previousCheckedValue = value; | ||
} | ||
/** | ||
* @override FormControlMixin | ||
*/ | ||
_onBeforeRepropagateChildrenValues(ev) { | ||
// Normalize target, since we might receive 'portal events' (from children in a modal, | ||
// see select-rich) | ||
const target = (ev.detail && ev.detail.element) || ev.target; | ||
if (this.multipleChoice || !target.checked) { | ||
return; | ||
} | ||
this.formElements.forEach(option => { | ||
if (target.choiceValue !== option.choiceValue) { | ||
option.checked = false; // eslint-disable-line no-param-reassign | ||
} | ||
}); | ||
this.__setChoiceGroupTouched(); | ||
this.requestUpdate('modelValue'); | ||
} | ||
}, | ||
); |
@@ -6,3 +6,4 @@ import { html, LitElement } from '@lion/core'; | ||
import { Required } from '@lion/validate'; | ||
import { expect, fixture, nextFrame } from '@open-wc/testing'; | ||
import { expect, nextFrame } from '@open-wc/testing'; | ||
import { formFixture as fixture } from '@lion/field/test-helpers.js'; | ||
import { ChoiceGroupMixin } from '../src/ChoiceGroupMixin.js'; | ||
@@ -198,17 +199,17 @@ import { ChoiceInputMixin } from '../src/ChoiceInputMixin.js'; | ||
el.formElements[0].checked = true; | ||
expect(counter).to.equal(2); // male becomes checked, female becomes unchecked | ||
expect(counter).to.equal(1); // male becomes checked, female becomes unchecked | ||
// not changed values trigger no event | ||
el.formElements[0].checked = true; | ||
expect(counter).to.equal(2); | ||
expect(counter).to.equal(1); | ||
el.formElements[2].checked = true; | ||
expect(counter).to.equal(4); // other becomes checked, male becomes unchecked | ||
expect(counter).to.equal(2); // other becomes checked, male becomes unchecked | ||
// not found values trigger no event | ||
el.modelValue = 'foo'; | ||
expect(counter).to.equal(4); | ||
expect(counter).to.equal(2); | ||
el.modelValue = 'male'; | ||
expect(counter).to.equal(6); // male becomes checked, other becomes unchecked | ||
expect(counter).to.equal(3); // male becomes checked, other becomes unchecked | ||
}); | ||
@@ -215,0 +216,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
59581
880
+ Added@lion/field@0.11.4(transitive)
- Removed@lion/field@0.11.3(transitive)
Updated@lion/field@0.11.4