Opened 2 years ago

Last modified 2 years ago

#15051 open bug

no callback for tooltip shown with a delay

Reported by: Jason Sachs Owned by:
Priority: blocker Milestone: 1.13.0
Component: ui.tooltip Version: 1.11.3
Keywords: Cc:
Blocked by: Blocking:

Description

There is the open() event callback for the tooltip widget but it gets called immediately when there is a trigger to open the tooltip. In my case I need to use a show: {delay: 500} to delay 500ms, and execute a callback when the tooltip is actually shown. There appears to be no way to do this with the existing version of code.

I'm looking at jquery.widget._show() and it does provide a callback, but the tooltip widget does not use this:

(from https://github.com/jquery/jquery-ui/blob/master/ui/widgets/tooltip.js#L322)

		this._show( tooltip, this.options.show );

		// Handle tracking tooltips that are shown with a delay (#8644). As soon
		// as the tooltip is visible, position the tooltip using the most recent
		// event.
		// Adds the check to add the timers only when both delay and track options are set (#14682)
		if ( this.options.track && this.options.show && this.options.show.delay ) {
			delayedShow = this.delayedShow = setInterval( function() {
				if ( tooltip.is( ":visible" ) ) {
					position( positionOption.of );
					clearInterval( delayedShow );
				}
			}, $.fx.interval );
		}

		this._trigger( "open", event, { tooltip: tooltip } );

Not sure what the change should be, but there ought to be some way to provide a callback function that is triggered when the tooltip is actually shown. (should open() get called later? should there be an _open() event as well? should the show options include a callback that is called when the show operation is complete?)

Change History (1)

comment:1 Changed 2 years ago by Scott González

Component: ui.coreui.tooltip
Milestone: none1.13.0
Priority: minorblocker
Status: newopen

To deal with this, we need to rename the existing open event to beforeOpen and add a new open event after _show() completes. This can't happen until 1.13.0 since it's a breaking change. We also need to update dialog to match.

Note: See TracTickets for help on using tickets.