Skip to content

[BUG] 66.68~83.35ms delay when delayShow and delayHide are set to 0 #1008

Closed
@knubie

Description

@knubie

Describe the bug
When the delayShow and delayHide props are set to 0, there is still a 66.68~83.35ms delay. At least 50ms of delay can be attributed to the debounce function wraping the handleShowTooltip and handleHideTooltip methods here:

// debounce handler to prevent call twice when
// mouse enter and focus events being triggered toggether
const debouncedHandleShowTooltip = debounce(handleShowTooltip, 50)
const debouncedHandleHideTooltip = debounce(handleHideTooltip, 50)

Removing the call to debounce drops the delay to 16.67~33.34ms. The problem is that debounce is calling the functions on the trailing edge of the delay as opposed to the leading edge. The function also accepts an immediate argument, but with the the way that debounce is implemented here, passing true for immediate just disables the function call entirely.

if (!immediate) {
func.apply(this, args)
}

I recommend taking a look at underscore.js for how to implement debounce with the immediate param.
https://underscorejs.org/docs/modules/debounce.html

Version of Package
v5.10.5

To Reproduce

  1. Create an anchor that has a hover state (used to compare with tooltip delay).
  2. Add a tooltip with 0 for delayShow and delayHide.
  3. Observe delay on both show and hide.

Expected behavior
The hiding and showing of the tooltip should track with the hover state of the anchor.

Screenshots
With debounce:

tooltip_delay2.mp4
tooltip_delay_list.mp4

Without debounce:

tooltip_no_delay.mp4
tooltip_no_delay_list.mp4

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions