From b14ea29fd0d63da5dfef496987d2ce83538cd0ad Mon Sep 17 00:00:00 2001 From: tulasigudibanda <47306803+tulasigudibanda@users.noreply.github.com> Date: Fri, 13 Dec 2024 08:31:38 -0600 Subject: [PATCH 1/2] fix(radio button): disable radio button (#295) * fix(radio button): disable radio button * fix: _handleSlotChange for radioButtonGroup * fix: removed requestUpdate * fix: call _updateChildren from _handleSlotChange and updated * docs: fix to connect hideCancelButton control in modal --------- Co-authored-by: Tulasi Gudibanda --- .../reusable/modal/modal.stories.js | 2 + .../reusable/radioButton/radioButton.scss | 2 + .../radioButton/radioButton.stories.js | 2 + .../reusable/radioButton/radioButtonGroup.ts | 57 +++++++------------ 4 files changed, 26 insertions(+), 37 deletions(-) diff --git a/src/components/reusable/modal/modal.stories.js b/src/components/reusable/modal/modal.stories.js index ae9c87d9..a3931e50 100644 --- a/src/components/reusable/modal/modal.stories.js +++ b/src/components/reusable/modal/modal.stories.js @@ -55,6 +55,7 @@ export const Modal = { ?destructive=${args.destructive} ?okDisabled=${args.okDisabled} ?hideFooter=${args.hideFooter} + ?hideCancelButton=${args.hideCancelButton} @on-close=${(e) => action(e.type)(e)} > Open Modal @@ -108,6 +109,7 @@ export const BeforeClose = { cancelText=${args.cancelText} ?destructive=${args.destructive} ?okDisabled=${args.okDisabled} + ?hideCancelButton=${args.hideCancelButton} .beforeClose=${(returnValue) => handleBeforeClose(returnValue)} @on-close=${(e) => action(e.type)(e)} > diff --git a/src/components/reusable/radioButton/radioButton.scss b/src/components/reusable/radioButton/radioButton.scss index 488e02ac..bedc34ba 100644 --- a/src/components/reusable/radioButton/radioButton.scss +++ b/src/components/reusable/radioButton/radioButton.scss @@ -72,6 +72,8 @@ input { &[disabled] { border-color: var(--kd-color-text-disabled); + opacity: 0.5; + cursor: not-allowed; &:hover { background-color: transparent; diff --git a/src/components/reusable/radioButton/radioButton.stories.js b/src/components/reusable/radioButton/radioButton.stories.js index 14fc1f56..e1f1bbe6 100644 --- a/src/components/reusable/radioButton/radioButton.stories.js +++ b/src/components/reusable/radioButton/radioButton.stories.js @@ -17,11 +17,13 @@ export const RadioButton = { args: { unnamed: 'Label', value: 'example', + disabled: false, }, render: (args) => { return html` action(e.type)(e)} > ${args.unnamed} diff --git a/src/components/reusable/radioButton/radioButtonGroup.ts b/src/components/reusable/radioButton/radioButtonGroup.ts index 48d190eb..1c57acea 100644 --- a/src/components/reusable/radioButton/radioButtonGroup.ts +++ b/src/components/reusable/radioButton/radioButtonGroup.ts @@ -90,12 +90,26 @@ export class RadioButtonGroup extends FormMixin(LitElement) { : null}
- +
`; } + private _handleSlotChange() { + this._updateChildren(); + } + + private _updateChildren() { + this.radioButtons.forEach((radio) => { + radio.disabled = this.disabled; + radio.checked = radio.value === this.value; + radio.name = this.name; + radio.required = this.required; + radio.invalid = this._isInvalid; + }); + } + override willUpdate(changedProps: any) { if (changedProps.has('textStrings')) { this._textStrings = deepmerge(_defaultTextStrings, this.textStrings); @@ -103,48 +117,17 @@ export class RadioButtonGroup extends FormMixin(LitElement) { } override updated(changedProps: any) { - // preserve FormMixin updated function this._onUpdated(changedProps); - if (changedProps.has('name')) { - // set name for each radio button - this.radioButtons.forEach((radio: any) => { - radio.name = this.name; - }); - } - - if (changedProps.has('value')) { - // set checked state for each radio button - this.radioButtons.forEach((radio: any) => { - radio.checked = radio.value === this.value; - }); - } - - if (changedProps.has('required')) { - // set required for each radio button - this.radioButtons.forEach((radio: any) => { - radio.required = this.required; - }); - } - - if ( - changedProps.has('disabled') && - changedProps.get('disabled') !== undefined - ) { - // set disabled for each radio button - this.radioButtons.forEach((radio: any) => { - radio.disabled = this.disabled; - }); - } - if ( + changedProps.has('value') || + changedProps.has('name') || + changedProps.has('required') || + changedProps.has('disabled') || changedProps.has('invalidText') || changedProps.has('internalValidationMsg') ) { - // set invalid state for each radio button - this.radioButtons.forEach((radio: any) => { - radio.invalid = this._isInvalid; - }); + this._updateChildren(); } } From fcd256ad772b2f61a2564b6463f9e53bc4f4f283 Mon Sep 17 00:00:00 2001 From: tulasigudibanda <47306803+tulasigudibanda@users.noreply.github.com> Date: Fri, 13 Dec 2024 08:44:15 -0600 Subject: [PATCH 2/2] fix: checkbox subgroup select all fix (#298) Co-authored-by: Tulasi Gudibanda --- src/components/reusable/checkbox/checkboxGroup.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/components/reusable/checkbox/checkboxGroup.ts b/src/components/reusable/checkbox/checkboxGroup.ts index d3098fe7..a4a4fc1f 100644 --- a/src/components/reusable/checkbox/checkboxGroup.ts +++ b/src/components/reusable/checkbox/checkboxGroup.ts @@ -332,6 +332,10 @@ export class CheckboxGroup extends FormMixin(LitElement) { } else { this.value = []; } + + this.checkboxes.forEach((checkbox: any) => { + checkbox.indeterminate = false; + }); } else { const newValues = [...this.value]; if (newValues.includes(value)) {