Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Fix async disable selection box #280

Merged
merged 11 commits into from
Jul 16, 2021
Merged

Conversation

bradenbiz
Copy link
Contributor

Bug:

disabling a selection box form control after initialization of the components led to some bad-looking css bugs.

Fix:

make sure each of the internal components (checkbox & radio) are properly passing the disabled state of the form control to each of the outer components (selection box), so that the css can be updated properly.

Changes made:

src/app/public/modules/checkbox/checkbox.component.spec.ts

  • modify SingleCheckboxComponent to have a ViewChild that grabs the SkyCheckboxComponent so that we can subscribe() to disabledChange values and call onDisabledChange() every time
  • write new test to spyOn() how many times onDisabledChange() is called, and use that to determine if the SkyCheckboxComponent is properly emitting new disabled values

src/app/public/modules/checkbox/checkbox.component.ts

  • use a getter pattern for the disabled variable
  • create the disabledChange emitter

src/app/public/modules/radio/fixtures/radio.component.fixture.html

  • move the disabling behavior from the second radio button to the first so to make the new test work as expected

src/app/public/modules/radio/fixtures/radio.component.fixture.ts

  • add a ViewChild that grabs the SkyRadioComponent so that we can subscribe() to disabledChange values and call onDisabledChange() every time

src/app/public/modules/radio/radio.component.spec.ts

  • write new test to spyOn() how many times onDisabledChange() is called, and use that to determine if the SkyRadioComponent is properly emitting new disabled values
  • modify existing test to work as it used to, but with the radio fixture's HTML changes

src/app/public/modules/radio/radio.component.ts

  • use a getter pattern for the disabled variable
  • create the disabledChange emitter

src/app/public/modules/selection-box/fixtures/selection-box-fixtures.module.ts

  • import the ReactiveFormsModule so to allow reactive forms to work in the selection box fixture

src/app/public/modules/selection-box/fixtures/selection-box.component.fixture.html

  • wrap the sky-selection-box components in a form
  • use the newly created FormControls to loop through the creation of the selection boxes
  • set up each of the checkbox components with a form control value

src/app/public/modules/selection-box/fixtures/selection-box.component.fixture.ts

  • rename variables
  • create and initialize the FormGroup as a FormArray with FormControls
  • create a getter for the new FormArray

src/app/public/modules/selection-box/selection-box.component.html

  • code styling

src/app/public/modules/selection-box/selection-box.component.spec.ts

  • write new test to disable/enable the selection and confirm that the proper css class has been added to it

src/app/public/modules/selection-box/selection-box.component.ts

  • markForCheck() every time disabled is set
  • subscribe() to disabledChange and update disabled every time a new value is pushed

src/app/visual/selection-box/selection-box-visual.component.html

  • wrap the sky-selection-box components in a form
  • use the newly created FormControls to loop through the creation of the selection boxes
  • set up each of the checkbox components with a form control value

src/app/visual/selection-box/selection-box-visual.component.ts

  • rename variables
  • create and initialize the FormGroup as a FormArray with FormControls
  • create a getter for the new FormArray

@blackbaud-ado
Copy link
Member

Copy link
Contributor

@Blackbaud-AlexKingman Blackbaud-AlexKingman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work on this! Just a few comments, but mostly code style stuff. Check out our guide here for more info: https://host.nxt.blackbaud.com/skyux-team-docs/style

Also, one last question: do we have a visual test that covers the disabled state? I'm pretty sure we do, just want to double check.

@bradenbiz
Copy link
Contributor Author

In reference to your question of if we have a visual test for disabling of the component, I believe this test is what you are looking for:

it('should match previous screenshot when disabled', async (done) => {
await SkyHostBrowser.scrollTo('#screenshot-selection-box-disabled');
await clickCheckbox();
expect('#screenshot-selection-box-disabled')
.toMatchBaselineScreenshot(done, {
screenshotName: getScreenshotName('selection-box-disabled')
});
});

@blackbaud-ado
Copy link
Member

@codecov
Copy link

codecov bot commented Jul 14, 2021

Codecov Report

Merging #280 (88b8211) into master (63bdf08) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #280   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           37        37           
  Lines         1081      1098   +17     
  Branches       209       212    +3     
=========================================
+ Hits          1081      1098   +17     
Impacted Files Coverage Δ
.../app/public/modules/checkbox/checkbox.component.ts 100.00% <100.00%> (ø)
src/app/public/modules/radio/radio.component.ts 100.00% <100.00%> (ø)
...c/modules/selection-box/selection-box.component.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 63bdf08...88b8211. Read the comment docs.

@blackbaud-ado
Copy link
Member

@@ -126,7 +140,7 @@ export class SkyCheckboxComponent implements ControlValueAccessor, OnInit {
}

/**
* Indicates whether the checkbox is selected.
* Indicates whether to the checkbox is selected.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did this to sneak in here accidentally?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, fixed!

<sky-checkbox-label>Disabled Checkbox</sky-checkbox-label>
<sky-checkbox
[checked]="false"
[disabled]="true">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Closing bracket > needs to be on a new line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weird... this is fixed locally, and it says i pushed my commit for that file. ill try pushing again

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nevermind, misread your comment. fixed in last commit!

@blackbaud-ado
Copy link
Member

Copy link
Contributor

@Blackbaud-AlexKingman Blackbaud-AlexKingman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 great job!

@blackbaud-ado
Copy link
Member

@bradenbiz bradenbiz merged commit 816a176 into master Jul 16, 2021
@bradenbiz bradenbiz deleted the fixAsyncDisableSelectionBox branch July 16, 2021 16:29
Blackbaud-PaulCrowder added a commit that referenced this pull request Jul 29, 2021
* Input box inline help (#265)

* initial work

* character-count

* padding tweaks

* build fix

* fixed merge

* final positioning for inline help widget

* visual test tweak, test fix

* style tweaks

* updated selector to use sky-control-help

Co-authored-by: Alex Kingman <alex.kingman@blackbaud.me>

* Build #skyux-forms-push-929062241-56873: Added new baseline screenshots. [ci skip]

* Update changelog/package.json for 4.19.0 release (#270)

Co-authored-by: Alex Kingman <alex.kingman@blackbaud.me>

* Fix single file attachment to show full file name in title attribute (#271)

* Update changelog/package.json for 4.19.1 release (#272)

* Added left inset icon for input-box; fix padding bug with country field (#273)

* Added left inset icon for input-box

* visual tweaks

* unit tests

* added scss variables

* fix country field spacing

Co-authored-by: Alex Kingman <alex.kingman@blackbaud.me>

* Build #skyux-forms-push-990175149-08428: Added new baseline screenshots. [ci skip]

* 4.20.0 release (#274)

* 4.20.0 release

* package lock

* Update CHANGELOG.md

Co-authored-by: Paula Hodgkins <77297281+blackbaud-paulah@users.noreply.github.com>

Co-authored-by: Alex Kingman <alex.kingman@blackbaud.me>
Co-authored-by: Paula Hodgkins <77297281+blackbaud-paulah@users.noreply.github.com>
Co-authored-by: John Lyons <John.Lyons@blackbaud.com>

* Fix docs for checkbox (#276)

* Fix async disable selection box (#280)

* all changes associated to trying to fix the selection box disable bug... WIP for Alex's review

* complete disable selection-box unit test. fix broken radio disable test.

* remove unnecesary local experimentation leftovers

* typo

* fixing things according to Alex's comments

* remove editor ruler and word wrap

* fix template style guide violations

* add disable/enable button to /visual selection-box component

* correct typo and a style guide violation

* missed style guide violation

* update changelog. skyux upgrade. (#282)

* update changelog. skyux upgrade.

* Update CHANGELOG.md

Co-authored-by: John Lyons <John.Lyons@blackbaud.com>

* Update CHANGELOG.md

Co-authored-by: John Lyons <John.Lyons@blackbaud.com>

Co-authored-by: John Lyons <John.Lyons@blackbaud.com>

* Fix overlapping input box value and label for textareas in modern theme (#279)

* Fix overlapping input box value and label for textareas in modern theme

* reverted accidental comments

* removed baselines to allow for tiny shift in padding

* fixed visual test

* fix e2e test

* e2e fix

Co-authored-by: Alex Kingman <alex.kingman@blackbaud.me>
Co-authored-by: Paul Crowder <paul.crowder@blackbaud.com>

* Build #skyux-forms-push-1049895399-36432: Added new baseline screenshots. [ci skip]

* Changelog update; redo 4.20.1 release (#283)

* changelog update

* Update CHANGELOG.md

Co-authored-by: John Lyons <John.Lyons@blackbaud.com>

* Update CHANGELOG.md

Co-authored-by: Alex Kingman <alex.kingman@blackbaud.me>
Co-authored-by: John Lyons <John.Lyons@blackbaud.com>

* Removed accidental disabled e2e tests for input box (#284)

Co-authored-by: Alex Kingman <alex.kingman@blackbaud.me>

Co-authored-by: Alex <alex.kingman@blackbaud.com>
Co-authored-by: Alex Kingman <alex.kingman@blackbaud.me>
Co-authored-by: Blackbaud Sky Build User <sky-build-user@blackbaud.com>
Co-authored-by: Steve Brush <steve.brush@blackbaud.com>
Co-authored-by: Paula Hodgkins <77297281+blackbaud-paulah@users.noreply.github.com>
Co-authored-by: John Lyons <John.Lyons@blackbaud.com>
Co-authored-by: Braden Bisping <63625452+bradenbiz@users.noreply.github.com>
johnhwhite added a commit that referenced this pull request Sep 30, 2021
* initial commit

* Updated singletons to use providedIn: root (#269)

Co-authored-by: Alex Kingman <alex.kingman@blackbaud.me>

* Merge from master (#275)

Co-authored-by: Alex Kingman <alex.kingman@blackbaud.me>

* provider updates, dependency updates, workflow updates (#277)

* provider updates, dependency updates, workflow updates

* revert

Co-authored-by: Alex Kingman <alex.kingman@blackbaud.me>

* 5.0.0-beta.0 release (#278)

Co-authored-by: Alex Kingman <alex.kingman@blackbaud.me>

* Deprecate SkySelectionBoxGridAlignItems (#281)

* Deprecate SkySelectionBoxGridAlignItems

* Export union type

* Merge master into 5.0.0-next (#285)

* Input box inline help (#265)

* initial work

* character-count

* padding tweaks

* build fix

* fixed merge

* final positioning for inline help widget

* visual test tweak, test fix

* style tweaks

* updated selector to use sky-control-help

Co-authored-by: Alex Kingman <alex.kingman@blackbaud.me>

* Build #skyux-forms-push-929062241-56873: Added new baseline screenshots. [ci skip]

* Update changelog/package.json for 4.19.0 release (#270)

Co-authored-by: Alex Kingman <alex.kingman@blackbaud.me>

* Fix single file attachment to show full file name in title attribute (#271)

* Update changelog/package.json for 4.19.1 release (#272)

* Added left inset icon for input-box; fix padding bug with country field (#273)

* Added left inset icon for input-box

* visual tweaks

* unit tests

* added scss variables

* fix country field spacing

Co-authored-by: Alex Kingman <alex.kingman@blackbaud.me>

* Build #skyux-forms-push-990175149-08428: Added new baseline screenshots. [ci skip]

* 4.20.0 release (#274)

* 4.20.0 release

* package lock

* Update CHANGELOG.md

Co-authored-by: Paula Hodgkins <77297281+blackbaud-paulah@users.noreply.github.com>

Co-authored-by: Alex Kingman <alex.kingman@blackbaud.me>
Co-authored-by: Paula Hodgkins <77297281+blackbaud-paulah@users.noreply.github.com>
Co-authored-by: John Lyons <John.Lyons@blackbaud.com>

* Fix docs for checkbox (#276)

* Fix async disable selection box (#280)

* all changes associated to trying to fix the selection box disable bug... WIP for Alex's review

* complete disable selection-box unit test. fix broken radio disable test.

* remove unnecesary local experimentation leftovers

* typo

* fixing things according to Alex's comments

* remove editor ruler and word wrap

* fix template style guide violations

* add disable/enable button to /visual selection-box component

* correct typo and a style guide violation

* missed style guide violation

* update changelog. skyux upgrade. (#282)

* update changelog. skyux upgrade.

* Update CHANGELOG.md

Co-authored-by: John Lyons <John.Lyons@blackbaud.com>

* Update CHANGELOG.md

Co-authored-by: John Lyons <John.Lyons@blackbaud.com>

Co-authored-by: John Lyons <John.Lyons@blackbaud.com>

* Fix overlapping input box value and label for textareas in modern theme (#279)

* Fix overlapping input box value and label for textareas in modern theme

* reverted accidental comments

* removed baselines to allow for tiny shift in padding

* fixed visual test

* fix e2e test

* e2e fix

Co-authored-by: Alex Kingman <alex.kingman@blackbaud.me>
Co-authored-by: Paul Crowder <paul.crowder@blackbaud.com>

* Build #skyux-forms-push-1049895399-36432: Added new baseline screenshots. [ci skip]

* Changelog update; redo 4.20.1 release (#283)

* changelog update

* Update CHANGELOG.md

Co-authored-by: John Lyons <John.Lyons@blackbaud.com>

* Update CHANGELOG.md

Co-authored-by: Alex Kingman <alex.kingman@blackbaud.me>
Co-authored-by: John Lyons <John.Lyons@blackbaud.com>

* Removed accidental disabled e2e tests for input box (#284)

Co-authored-by: Alex Kingman <alex.kingman@blackbaud.me>

Co-authored-by: Alex <alex.kingman@blackbaud.com>
Co-authored-by: Alex Kingman <alex.kingman@blackbaud.me>
Co-authored-by: Blackbaud Sky Build User <sky-build-user@blackbaud.com>
Co-authored-by: Steve Brush <steve.brush@blackbaud.com>
Co-authored-by: Paula Hodgkins <77297281+blackbaud-paulah@users.noreply.github.com>
Co-authored-by: John Lyons <John.Lyons@blackbaud.com>
Co-authored-by: Braden Bisping <63625452+bradenbiz@users.noreply.github.com>

* Release 5.0.0-beta.1 (#286)

* Next > Adopt Angular CLI (#288)

* Release 5.0.0-beta.2 (#289)

* Build #skyux-forms-push-1198364695-34681: Added new baseline screenshots. [ci skip]

* Remove circular references (#290)

* Fix visual tests

* Fix import paths

* Update packages

* Delete screenshots

* Build #skyux-forms-push-1210649827-68966: Added new baseline screenshots. [ci skip]

* Release 5.0.0-beta.3 (#291)

* Next > Update peer dependencies (#292)

* Build #skyux-forms-push-1221916356-27461: Added new baseline screenshots. [ci skip]

* 5.0.0-beta.5 release; removed unnecessary dependency on @skyux/modals (#293)

* Removed modals

* 5.0.0-beta.5-release

* Update CHANGELOG.md

* baselines

Co-authored-by: Alex Kingman <alex.kingman@blackbaud.me>

* Build #skyux-forms-push-1234569693-21840: Added new baseline screenshots. [ci skip]

* Document sky-control-help class (#295)

* Document sky-control-help class

* Update dependencies as per error messages

* package.lock

* reset baselines

Co-authored-by: John Lyons <John.Lyons@blackbaud.me>
Co-authored-by: Alex Kingman <alex.kingman@blackbaud.me>

* Build #skyux-forms-push-1258643898-83004: Added new baseline screenshots. [ci skip]

* Workflow and package updates

* Fix tests

* Reset screenshot

* Reset screenshot

* Exact dependencies

* @skyux/packages as prod dependency

* Reset screenshots

* Fix tests

* Reset screenshots

Co-authored-by: Alex Kingman <alex.kingman@blackbaud.me>
Co-authored-by: Alex <alex.kingman@blackbaud.com>
Co-authored-by: Paul Crowder <paul.crowder@blackbaud.com>
Co-authored-by: Blackbaud Sky Build User <sky-build-user@blackbaud.com>
Co-authored-by: Steve Brush <steve.brush@blackbaud.com>
Co-authored-by: Paula Hodgkins <77297281+blackbaud-paulah@users.noreply.github.com>
Co-authored-by: John Lyons <John.Lyons@blackbaud.com>
Co-authored-by: Braden Bisping <63625452+bradenbiz@users.noreply.github.com>
Co-authored-by: John Lyons <John.Lyons@blackbaud.me>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
4 participants