MCPcopy Create free account
hub / github.com/microsoft/SandDance / TooltipHostBase1

Function TooltipHostBase1

docs/app/js/sanddance-app.js:42470–42567  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

42468 (0, _tslib.__extends)(TooltipHostBase1, _super);
42469 // Constructor
42470 function TooltipHostBase1(props) {
42471 var _this = _super.call(this, props) || this;
42472 // The wrapping div that gets the hover events
42473 _this._tooltipHost = _react.createRef();
42474 _this._defaultTooltipId = (0, _utilities.getId)("tooltip");
42475 _this.show = function() {
42476 _this._toggleTooltip(true);
42477 };
42478 _this.dismiss = function() {
42479 _this._hideTooltip();
42480 };
42481 _this._getTargetElement = function() {
42482 if (!_this._tooltipHost.current) return undefined;
42483 var overflowMode = _this.props.overflowMode;
42484 // Select target element based on overflow mode. For parent mode, you want to position the tooltip relative
42485 // to the parent element, otherwise it might look off.
42486 if (overflowMode !== undefined) switch(overflowMode){
42487 case (0, _tooltipHostTypes.TooltipOverflowMode).Parent:
42488 return _this._tooltipHost.current.parentElement;
42489 case (0, _tooltipHostTypes.TooltipOverflowMode).Self:
42490 return _this._tooltipHost.current;
42491 }
42492 return _this._tooltipHost.current;
42493 };
42494 // Show Tooltip
42495 _this._onTooltipMouseEnter = function(ev) {
42496 var _a = _this.props, overflowMode = _a.overflowMode, delay = _a.delay;
42497 if (TooltipHostBase1._currentVisibleTooltip && TooltipHostBase1._currentVisibleTooltip !== _this) TooltipHostBase1._currentVisibleTooltip.dismiss();
42498 TooltipHostBase1._currentVisibleTooltip = _this;
42499 if (overflowMode !== undefined) {
42500 var overflowElement = _this._getTargetElement();
42501 if (overflowElement && !(0, _utilities.hasOverflow)(overflowElement)) return;
42502 }
42503 if (ev.target && (0, _utilities.portalContainsElement)(ev.target, _this._getTargetElement())) // Do not show tooltip when target is inside a portal relative to TooltipHost.
42504 return;
42505 _this._clearDismissTimer();
42506 _this._clearOpenTimer();
42507 if (delay !== (0, _tooltipTypes.TooltipDelay).zero) {
42508 var delayTime = _this._getDelayTime(delay); // non-null assertion because we set it in `defaultProps`
42509 _this._openTimerId = _this._async.setTimeout(function() {
42510 _this._toggleTooltip(true);
42511 }, delayTime);
42512 } else _this._toggleTooltip(true);
42513 };
42514 // Hide Tooltip
42515 _this._onTooltipMouseLeave = function(ev) {
42516 var closeDelay = _this.props.closeDelay;
42517 _this._clearDismissTimer();
42518 _this._clearOpenTimer();
42519 if (closeDelay) _this._dismissTimerId = _this._async.setTimeout(function() {
42520 _this._toggleTooltip(false);
42521 }, closeDelay);
42522 else _this._toggleTooltip(false);
42523 if (TooltipHostBase1._currentVisibleTooltip === _this) TooltipHostBase1._currentVisibleTooltip = undefined;
42524 };
42525 _this._onTooltipKeyDown = function(ev) {
42526 if ((ev.which === (0, _utilities.KeyCodes).escape || ev.ctrlKey) && _this.state.isTooltipVisible) {
42527 _this._hideTooltip();

Callers

nothing calls this directly

Calls 1

stopPropagationMethod · 0.45

Tested by

no test coverage detected