@atlaskit/smart-card 20.0.1 → 20.0.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 20.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`12950ccea1b`](https://bitbucket.org/atlassian/atlassian-frontend/commits/12950ccea1b) - Hover Preview: Stop hover preview from propagating click event to parent element
8
+
3
9
  ## 20.0.1
4
10
 
5
11
  ### Patch Changes
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "20.0.1",
3
+ "version": "20.0.2",
4
4
  "sideEffects": false
5
5
  }
@@ -13,6 +13,8 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
13
13
 
14
14
  var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
15
15
 
16
+ var _react = require("react");
17
+
16
18
  var _reactIntlNext = require("react-intl-next");
17
19
 
18
20
  var _core = require("@emotion/core");
@@ -62,10 +64,15 @@ var ActionGroup = function ActionGroup(_ref) {
62
64
  testId = _ref.testId;
63
65
  var isMoreThenTwoItems = items.length > visibleButtonsNum;
64
66
  var firstActions = isMoreThenTwoItems ? items.slice(0, visibleButtonsNum - 1) : items;
65
- var restActions = isMoreThenTwoItems ? items.slice(visibleButtonsNum - 1) : [];
67
+ var restActions = isMoreThenTwoItems ? items.slice(visibleButtonsNum - 1) : []; // Stop AK dropdown menu to propagate event on click.
68
+
69
+ var onClick = (0, _react.useCallback)(function (e) {
70
+ return e.stopPropagation();
71
+ }, []);
66
72
  return (0, _core.jsx)("div", {
67
73
  css: styles,
68
- className: "actions-button-group"
74
+ className: "actions-button-group",
75
+ onClick: onClick
69
76
  }, (0, _core.jsx)(_buttonGroup.default, null, (0, _utils.renderActionItems)(firstActions, size, appearance), restActions.length > 0 ? (0, _core.jsx)(_dropdownMenu.default, {
70
77
  onOpenChange: function onOpenChange(_ref2) {
71
78
  var isOpen = _ref2.isOpen;
@@ -7,7 +7,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
7
7
  Object.defineProperty(exports, "__esModule", {
8
8
  value: true
9
9
  });
10
- exports.HoverCardComponent = exports.HoverCard = void 0;
10
+ exports.hoverCardClassName = exports.HoverCardComponent = exports.HoverCard = void 0;
11
11
 
12
12
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
13
 
@@ -42,6 +42,9 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
42
42
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
43
43
 
44
44
  /** @jsx jsx */
45
+ var hoverCardClassName = 'smart-links-hover-preview';
46
+ exports.hoverCardClassName = hoverCardClassName;
47
+
45
48
  var HoverCardComponent = function HoverCardComponent(_ref) {
46
49
  var children = _ref.children,
47
50
  id = _ref.id,
@@ -105,7 +108,11 @@ var HoverCardComponent = function HoverCardComponent(_ref) {
105
108
  if (actionId === 'preview-content') {
106
109
  hideCard();
107
110
  }
108
- }, [hideCard]);
111
+ }, [hideCard]); // Stop hover preview content to propagate event to parent.
112
+
113
+ var onClick = (0, _react.useCallback)(function (e) {
114
+ return e.stopPropagation();
115
+ }, []);
109
116
  return (0, _core.jsx)(_popup.default, {
110
117
  testId: "hover-card",
111
118
  isOpen: isOpen,
@@ -116,7 +123,9 @@ var HoverCardComponent = function HoverCardComponent(_ref) {
116
123
  return (0, _core.jsx)("div", {
117
124
  onMouseEnter: initShowCard,
118
125
  onMouseLeave: initHideCard,
119
- css: _styled.HoverCardContainer
126
+ className: hoverCardClassName,
127
+ css: _styled.HoverCardContainer,
128
+ onClick: onClick
120
129
  }, (0, _core.jsx)(_hoverCardContent.default, {
121
130
  analytics: analytics,
122
131
  cardActions: linkActions,
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "20.0.1",
3
+ "version": "20.0.2",
4
4
  "sideEffects": false
5
5
  }
@@ -1,6 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
 
3
3
  /** @jsx jsx */
4
+ import { useCallback } from 'react';
4
5
  import { FormattedMessage } from 'react-intl-next';
5
6
  import { css, jsx } from '@emotion/core';
6
7
  import ButtonGroup from '@atlaskit/button/button-group';
@@ -47,10 +48,13 @@ const ActionGroup = ({
47
48
  }) => {
48
49
  const isMoreThenTwoItems = items.length > visibleButtonsNum;
49
50
  const firstActions = isMoreThenTwoItems ? items.slice(0, visibleButtonsNum - 1) : items;
50
- const restActions = isMoreThenTwoItems ? items.slice(visibleButtonsNum - 1) : [];
51
+ const restActions = isMoreThenTwoItems ? items.slice(visibleButtonsNum - 1) : []; // Stop AK dropdown menu to propagate event on click.
52
+
53
+ const onClick = useCallback(e => e.stopPropagation(), []);
51
54
  return jsx("div", {
52
55
  css: styles,
53
- className: "actions-button-group"
56
+ className: "actions-button-group",
57
+ onClick: onClick
54
58
  }, jsx(ButtonGroup, null, renderActionItems(firstActions, size, appearance), restActions.length > 0 ? jsx(DropdownMenu, {
55
59
  onOpenChange: ({
56
60
  isOpen
@@ -13,6 +13,7 @@ import { useSmartLinkAnalytics } from '../../state/analytics';
13
13
  import { useSmartLinkRenderers } from '../../state/renderers';
14
14
  import HoverCardContent from './components/hover-card-content';
15
15
  import { HOVER_CARD_ANALYTICS_DISPLAY } from './utils';
16
+ export const hoverCardClassName = 'smart-links-hover-preview';
16
17
  export const HoverCardComponent = ({
17
18
  children,
18
19
  id,
@@ -70,7 +71,9 @@ export const HoverCardComponent = ({
70
71
  if (actionId === 'preview-content') {
71
72
  hideCard();
72
73
  }
73
- }, [hideCard]);
74
+ }, [hideCard]); // Stop hover preview content to propagate event to parent.
75
+
76
+ const onClick = useCallback(e => e.stopPropagation(), []);
74
77
  return jsx(Popup, {
75
78
  testId: "hover-card",
76
79
  isOpen: isOpen,
@@ -81,7 +84,9 @@ export const HoverCardComponent = ({
81
84
  }) => jsx("div", {
82
85
  onMouseEnter: initShowCard,
83
86
  onMouseLeave: initHideCard,
84
- css: HoverCardContainer
87
+ className: hoverCardClassName,
88
+ css: HoverCardContainer,
89
+ onClick: onClick
85
90
  }, jsx(HoverCardContent, {
86
91
  analytics: analytics,
87
92
  cardActions: linkActions,
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "20.0.1",
3
+ "version": "20.0.2",
4
4
  "sideEffects": false
5
5
  }
@@ -6,6 +6,7 @@ var _excluded = ["triggerRef"];
6
6
  var _templateObject;
7
7
 
8
8
  /** @jsx jsx */
9
+ import { useCallback } from 'react';
9
10
  import { FormattedMessage } from 'react-intl-next';
10
11
  import { css, jsx } from '@emotion/core';
11
12
  import ButtonGroup from '@atlaskit/button/button-group';
@@ -39,10 +40,15 @@ var ActionGroup = function ActionGroup(_ref) {
39
40
  testId = _ref.testId;
40
41
  var isMoreThenTwoItems = items.length > visibleButtonsNum;
41
42
  var firstActions = isMoreThenTwoItems ? items.slice(0, visibleButtonsNum - 1) : items;
42
- var restActions = isMoreThenTwoItems ? items.slice(visibleButtonsNum - 1) : [];
43
+ var restActions = isMoreThenTwoItems ? items.slice(visibleButtonsNum - 1) : []; // Stop AK dropdown menu to propagate event on click.
44
+
45
+ var onClick = useCallback(function (e) {
46
+ return e.stopPropagation();
47
+ }, []);
43
48
  return jsx("div", {
44
49
  css: styles,
45
- className: "actions-button-group"
50
+ className: "actions-button-group",
51
+ onClick: onClick
46
52
  }, jsx(ButtonGroup, null, renderActionItems(firstActions, size, appearance), restActions.length > 0 ? jsx(DropdownMenu, {
47
53
  onOpenChange: function onOpenChange(_ref2) {
48
54
  var isOpen = _ref2.isOpen;
@@ -14,6 +14,7 @@ import { useSmartLinkAnalytics } from '../../state/analytics';
14
14
  import { useSmartLinkRenderers } from '../../state/renderers';
15
15
  import HoverCardContent from './components/hover-card-content';
16
16
  import { HOVER_CARD_ANALYTICS_DISPLAY } from './utils';
17
+ export var hoverCardClassName = 'smart-links-hover-preview';
17
18
  export var HoverCardComponent = function HoverCardComponent(_ref) {
18
19
  var children = _ref.children,
19
20
  id = _ref.id,
@@ -77,7 +78,11 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
77
78
  if (actionId === 'preview-content') {
78
79
  hideCard();
79
80
  }
80
- }, [hideCard]);
81
+ }, [hideCard]); // Stop hover preview content to propagate event to parent.
82
+
83
+ var onClick = useCallback(function (e) {
84
+ return e.stopPropagation();
85
+ }, []);
81
86
  return jsx(Popup, {
82
87
  testId: "hover-card",
83
88
  isOpen: isOpen,
@@ -88,7 +93,9 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
88
93
  return jsx("div", {
89
94
  onMouseEnter: initShowCard,
90
95
  onMouseLeave: initHideCard,
91
- css: HoverCardContainer
96
+ className: hoverCardClassName,
97
+ css: HoverCardContainer,
98
+ onClick: onClick
92
99
  }, jsx(HoverCardContent, {
93
100
  analytics: analytics,
94
101
  cardActions: linkActions,
@@ -1,4 +1,5 @@
1
1
  import React, { FC } from 'react';
2
2
  import { HoverCardProps } from './types';
3
+ export declare const hoverCardClassName = "smart-links-hover-preview";
3
4
  export declare const HoverCardComponent: FC<HoverCardProps>;
4
5
  export declare const HoverCard: React.ForwardRefExoticComponent<Pick<Omit<React.PropsWithChildren<HoverCardProps>, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "children" | "id" | "analyticsContext" | "key" | "url"> & React.RefAttributes<any>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "20.0.1",
3
+ "version": "20.0.2",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"