Merge pull request #17397 from hiroshisuga/dev2.6.1_tooltip

[2.6 fix] Show the pan tool tip at the same timing and position as other tools
This commit is contained in:
Ramón Souza 2023-04-11 13:18:18 -03:00 committed by GitHub
commit fb308f0a60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 5 deletions

View File

@ -123,6 +123,8 @@ export default class Button extends BaseButton {
'aria-label': ariaLabel,
'aria-expanded': ariaExpanded,
tooltipLabel,
tooltipdelay,
tooltipplacement,
} = this.props;
const renderFuncName = circle ? 'renderCircle' : 'renderDefault';
@ -132,6 +134,8 @@ export default class Button extends BaseButton {
return (
<TooltipContainer
title={tooltipLabel || buttonLabel}
delay={tooltipdelay}
placement={tooltipplacement}
>
{this[renderFuncName]()}
</TooltipContainer>

View File

@ -57,10 +57,20 @@ class Tooltip extends Component {
const {
position,
title,
delay,
placement,
} = this.props;
const { animations } = Settings.application;
const overridePlacement = placement ? placement : position;
let overrideDelay;
if (animations) {
overrideDelay = delay ? [delay, ANIMATION_DELAY[1]] : ANIMATION_DELAY;
} else {
overrideDelay = delay ? [delay, 0] : [ANIMATION_DELAY[0], 0];
}
const options = {
aria: null,
allowHTML: false,
@ -69,14 +79,14 @@ class Tooltip extends Component {
arrow: roundArrow,
boundary: 'window',
content: title,
delay: animations ? ANIMATION_DELAY : [ANIMATION_DELAY[0], 0],
delay: overrideDelay,
duration: animations ? ANIMATION_DURATION : 0,
interactive: true,
interactiveBorder: 10,
onShow: this.onShow,
onHide: this.onHide,
offset: TIP_OFFSET,
placement: position,
placement: overridePlacement,
touch: 'hold',
theme: 'bbbtip',
multiple: false,
@ -101,12 +111,15 @@ class Tooltip extends Component {
return true;
}).forEach((e) => {
const instance = e._tippy;
instance.setProps({
const newProps = {
animation: animations
? DEFAULT_ANIMATION : ANIMATION_NONE,
delay: animations ? ANIMATION_DELAY : [ANIMATION_DELAY[0], 0],
duration: animations ? ANIMATION_DURATION : 0,
});
};
if (!e.getAttribute("delay")) {
newProps["delay"] = animations ? ANIMATION_DELAY : [ANIMATION_DELAY[0], 0];
}
instance.setProps(newProps);
});
const elem = document.getElementById(this.tippySelectorId);

View File

@ -89,6 +89,8 @@ class PanToolInjector extends React.Component {
size="md"
label={label}
aria-label={label}
tooltipdelay={700}
tooltipplacement="top"
onClick={() => {
setPanSelected(true);
setIsPanning(true);