Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upSticky popovers and tooltips #3794
Conversation
…cused. Not yet working as intended.
…ered. Do not close on focusout when popover is focused.
… when they are focusable (i.e., when they track focusin and focusout events)
…se they are already handled in accordance with the autoClose parameter. Fixes e2e tests.
* | ||
* @since *Unreleased* | ||
*/ | ||
@Input() mouseleaveCloseDelay: number; |
earshinov
Jun 29, 2020
Author
Do I need to prepare API documentation other than these comments?
Do I need to prepare API documentation other than these comments?
* The delay before the popover is closed on mouseleave. Only takes effect if "mouseleave" is among the close | ||
* triggers. | ||
* | ||
* @since *Unreleased* |
earshinov
Jun 29, 2020
Author
*Unreleased*
to be replaced with an appropriate version at the time of merge.
*Unreleased*
to be replaced with an appropriate version at the time of merge.
Hey @earshinov! Sorry to comment out this late on your PR. Allow me to challenge you that what you try to fix in this PR is not needed in the first place. My main concern was to try to give some answers somehow based on your description
I have gathered my solution in a StackBlitz available here |
Before submitting a pull request, please make sure you have at least performed the following:
This PR attempts to solve the problem described in #2169,
Motivation
In our project we have popovers with information that users might like to copy, and also popovers with links for users to click. I consider these scenarios fairly basic and common, but ngbPopover doesn't really support them because it closes as soon as the user moves the mouse out of the element the popover is bound to (I will call it the target element from here on).
Here are some "solutions" we considered:
[closeDelay]
large enough for users to be able to click a link before the popup closesNone of these are acceptable.
Proposal
The basic idea is to listen to trigger events both on the target element AND the popover element. To illustrate, in case of
triggers="mouseenter:mouseleave"
the popover will close onmouseleave
UNLESSmouseenter
was triggered when the user moved the cursor from the target element to the popover.Of course, the cursor isn't moved instantaneously, so some delay is required. You can find it in the new
NgbPopoverConfig.mouseleaveCloseDelay
field andNgbPopover.mouseleaveCloseDelay
input. I chose 100 ms as the default, but you are welcome to suggest any other positive number. I will tell you more, there is a similar field and a similar input forfocusout
as well.You might argue that this approach is wrong and these events shouldn't be treated as special citizens. Maybe they shouldn't, but although I am open to suggestions regarding design and refactoring I would prefer to keep the code dumb and not over-complicate things until the basic idea is approved and my approach reviewed and tested. (Also I must note here that events will need to be handled differently anyway because they require different delays: mouse movement does not happen instantly while clicks and focus changes do.)
Among the enhancements themselves this PR includes:
There are some technical details I would like to point out:
tabIndex
)autoClose
.Update: fixed some typos.