@bpmn-io/properties-panel 3.3.0 → 3.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -273,18 +273,25 @@ function Tooltip(props) {
273
273
  parent
274
274
  } = props;
275
275
  const [visible, setShow] = hooks.useState(false);
276
+ const [focusedViaKeyboard, setFocusedViaKeyboard] = hooks.useState(false);
276
277
  let timeout = null;
277
278
  const wrapperRef = hooks.useRef(null);
278
279
  const tooltipRef = hooks.useRef(null);
279
280
  const showTooltip = async event => {
280
- const show = () => !visible && setShow(true);
281
- if (event instanceof MouseEvent) {
282
- timeout = setTimeout(show, 200);
283
- } else {
284
- show();
281
+ const show = () => setShow(true);
282
+ if (!visible && !timeout) {
283
+ if (event instanceof MouseEvent) {
284
+ timeout = setTimeout(show, 200);
285
+ } else {
286
+ show();
287
+ setFocusedViaKeyboard(true);
288
+ }
285
289
  }
286
290
  };
287
- const hideTooltip = () => setShow(false);
291
+ const hideTooltip = () => {
292
+ setShow(false);
293
+ setFocusedViaKeyboard(false);
294
+ };
288
295
  const hideTooltipViaEscape = e => {
289
296
  e.code === 'Escape' && hideTooltip();
290
297
  };
@@ -308,7 +315,7 @@ function Tooltip(props) {
308
315
  if (visible && !isTooltipHovered({
309
316
  x: e.x,
310
317
  y: e.y
311
- }) && !isFocused) {
318
+ }) && !(isFocused && focusedViaKeyboard)) {
312
319
  hideTooltip();
313
320
  }
314
321
  };
@@ -316,8 +323,8 @@ function Tooltip(props) {
316
323
  const {
317
324
  relatedTarget
318
325
  } = e;
319
- const isTooltipChild = el => el && !!el.closest('.bio-properties-panel-tooltip');
320
- if (visible && !isHovered(wrapperRef.current) && !isTooltipChild(relatedTarget)) {
326
+ const isTooltipChild = el => !!el.closest('.bio-properties-panel-tooltip');
327
+ if (visible && !isHovered(wrapperRef.current) && relatedTarget && !isTooltipChild(relatedTarget)) {
321
328
  hideTooltip();
322
329
  }
323
330
  };
@@ -329,7 +336,7 @@ function Tooltip(props) {
329
336
  document.removeEventListener('mousemove', hideHoveredTooltip);
330
337
  document.removeEventListener('focusout', hideFocusedTooltip);
331
338
  };
332
- }, [wrapperRef.current, visible]);
339
+ }, [wrapperRef.current, visible, focusedViaKeyboard]);
333
340
  const renderTooltip = () => {
334
341
  return jsxRuntime.jsxs("div", {
335
342
  class: "bio-properties-panel-tooltip",
@@ -352,12 +359,12 @@ function Tooltip(props) {
352
359
  tabIndex: "0",
353
360
  ref: wrapperRef,
354
361
  onMouseEnter: showTooltip,
355
- onMouseLeave: () => clearTimeout(timeout),
362
+ onMouseLeave: () => {
363
+ clearTimeout(timeout);
364
+ timeout = null;
365
+ },
356
366
  onFocus: showTooltip,
357
367
  onKeyDown: hideTooltipViaEscape,
358
- onMouseDown: e => {
359
- e.preventDefault();
360
- },
361
368
  children: [props.children, visible ? parent ? compat.createPortal(renderTooltip(), parent.current) : renderTooltip() : null]
362
369
  });
363
370
  }
@@ -703,7 +710,8 @@ function Group(props) {
703
710
  class: classnames__default["default"]('bio-properties-panel-group-header', edited ? '' : 'empty', open ? 'open' : '', sticky && open ? 'sticky' : ''),
704
711
  onClick: toggleOpen,
705
712
  children: [jsxRuntime.jsx("div", {
706
- title: label,
713
+ title: props.tooltip ? null : label,
714
+ "data-title": label,
707
715
  class: "bio-properties-panel-group-header-title",
708
716
  children: jsxRuntime.jsx(TooltipWrapper, {
709
717
  value: props.tooltip,
@@ -3028,7 +3036,8 @@ function ListGroup(props) {
3028
3036
  class: classnames__default["default"]('bio-properties-panel-group-header', hasItems ? '' : 'empty', hasItems && open ? 'open' : '', sticky && open ? 'sticky' : ''),
3029
3037
  onClick: hasItems ? toggleOpen : noop$1,
3030
3038
  children: [jsxRuntime.jsx("div", {
3031
- title: label,
3039
+ title: props.tooltip ? null : label,
3040
+ "data-title": label,
3032
3041
  class: "bio-properties-panel-group-header-title",
3033
3042
  children: jsxRuntime.jsx(TooltipWrapper, {
3034
3043
  value: props.tooltip,