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

Popover hover close fix #1884

Merged
merged 18 commits into from
Aug 17, 2018
Merged

Conversation

Blackbaud-TrevorBurch
Copy link
Member

#1816

I tested multiple intervals and found that 200ms was the minimum that could be used to ensure closure in all cases.

@Blackbaud-AlexKingman Blackbaud-AlexKingman self-assigned this Aug 7, 2018
@codecov-io
Copy link

codecov-io commented Aug 7, 2018

Codecov Report

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

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #1884   +/-   ##
======================================
  Coverage     100%    100%           
======================================
  Files         415     415           
  Lines        8746    8750    +4     
  Branches     1292    1292           
======================================
+ Hits         8746    8750    +4
Impacted Files Coverage Δ
src/modules/popover/popover.component.ts 100% <ø> (ø) ⬆️
src/modules/popover/popover.directive.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 f8359c6...fd96954. Read the comment docs.

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.

Looks good. Ship it!

@@ -139,7 +139,7 @@ export class SkyPopoverDirective implements OnChanges, OnDestroy {
this.closePopover();
}
}
});
}, 200);

Choose a reason for hiding this comment

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

I would avoid "guessing" which value works here (some browsers might take longer than others to process events), and try something more predictable. This worked for me locally:

import 'rxjs/add/operator/take';

Observable
  .fromEvent(element, 'mouseleave')
  .takeUntil(this.idled)
  .subscribe((event: MouseEvent) => {
    this.skyPopover.isMouseEnter = false;

    if (this.skyPopoverTrigger === 'mouseenter') {
      event.preventDefault();

      if (this.skyPopover.isOpen) {
        this.closePopover();
      } else {
        // If the mouse leaves before the popover is open,
        // wait for the transition to complete before closing it.
        this.skyPopover.popoverOpened.take(1).subscribe(() => {
          this.closePopover();
        });
      }
    }
  });

this.windowRef.getWindow().setTimeout(() => {
if (this.isPopoverOpen()) {
if (this.skyPopover.isMouseEnter) {
this.skyPopover.markForCloseOnMouseLeave();
Copy link
Member

@Blackbaud-SteveBrush Blackbaud-SteveBrush Aug 16, 2018

Choose a reason for hiding this comment

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

@Blackbaud-TrevorBurch The popover's markForCloseOnMouseLeave() method is no longer being used, but we can't remove it since it would be a breaking change. Do you mind adding a // TODO: ... comment above the method so we don't forget to remove it when we make breaking changes?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure! Done!

// Give the popover a chance to set its isMouseEnter flag before checking to see
// if it should be closed.
this.windowRef.getWindow().setTimeout(() => {
this.closePopoeverOrMarkForClose();

Choose a reason for hiding this comment

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

The method is misspelled :(

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.... sorry about that.

@Blackbaud-TrevorBurch Blackbaud-TrevorBurch merged commit 19559a6 into master Aug 17, 2018
@Blackbaud-AlexKingman Blackbaud-AlexKingman deleted the 1816-popover-hover-timeout branch August 28, 2018 13:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants