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

Fixed dropdown positioning lag; bad unit test #1655

Merged
merged 1 commit into from
Apr 26, 2018

Conversation

Blackbaud-SteveBrush
Copy link
Member

  • The dropdown repositions itself on scroll and resize events. On the master branch, there is a noticeable "lag" when it's rewriting the top and left pixel values. This branch fixes that.
  • I also noticed a "bad" unit test for the Timepicker.

@@ -23,19 +22,20 @@ describe('Dropdown component', () => {
let fixture: ComponentFixture<DropdownTestComponent>;
let component: DropdownTestComponent;

beforeEach(async(() => {
beforeEach(() => {
Copy link
Member Author

Choose a reason for hiding this comment

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

This change is inconsequential; compileComponents() is not needed when running in AoT mode.

@@ -342,8 +342,7 @@ describe('SkyPopoverComponent', () => {
expect(component.placement).toEqual('right');

component.reposition();
expect(component.placement).toEqual('above');
tick();
expect(spy.calls.argsFor(1)[1]).toEqual('above');
Copy link
Member Author

Choose a reason for hiding this comment

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

This is a better way to write this test: checking which value is provided to getPopoverPosition().

@@ -160,13 +160,11 @@ export class SkyPopoverComponent implements OnInit, OnDestroy {
this.placement = this.preferredPlacement;
this.changeDetector.markForCheck();

this.windowRef.getWindow().setTimeout(() => {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the line that was causing the lag; it's running a setTimeout during every reposition call (not good).

const dropdown = fixture.nativeElement.querySelector('.sky-popover-container') as HTMLElement;
expect(dropdown.classList.contains('sky-popover-hidden')).toEqual(false);
const hiddenPopover = fixture.nativeElement.querySelector('.sky-popover-hidden') as HTMLElement;
expect(hiddenPopover).not.toBeNull();
Copy link
Member Author

Choose a reason for hiding this comment

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

I found this bad test during my work on this bugfix. We were supposed to be checking if the popover had closed!

@codecov-io
Copy link

Codecov Report

Merging #1655 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1655   +/-   ##
=======================================
  Coverage   99.98%   99.98%           
=======================================
  Files         395      395           
  Lines        8108     8108           
  Branches     1194     1194           
=======================================
  Hits         8107     8107           
  Misses          1        1
Impacted Files Coverage Δ
src/modules/popover/popover.component.ts 100% <100%> (ø) ⬆️
src/modules/dropdown/dropdown.component.ts 100% <100%> (ø) ⬆️

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 10b2b3d...9ce4ae3. Read the comment docs.

@Blackbaud-SteveBrush Blackbaud-SteveBrush merged commit a3ed040 into master Apr 26, 2018
@Blackbaud-SteveBrush Blackbaud-SteveBrush deleted the fix-dropdown-lag branch April 26, 2018 15:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants