@atlaskit/navigation-system 2.5.0 → 2.6.1

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,20 @@
1
1
  # @atlassian/navigation-system
2
2
 
3
+ ## 2.6.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`2445e6e19f1c7`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2445e6e19f1c7) -
8
+ pass testId to menuList
9
+
10
+ ## 2.6.0
11
+
12
+ ### Minor Changes
13
+
14
+ - [`e9ddf34435a22`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e9ddf34435a22) -
15
+ Clicking dropdown menu items will no longer collapse the side navigation on mobile. This change is
16
+ behind a feature flag.
17
+
3
18
  ## 2.5.0
4
19
 
5
20
  ### Minor Changes
@@ -46,7 +46,8 @@ var ExpandableMenuItem = exports.ExpandableMenuItem = /*#__PURE__*/(0, _react.fo
46
46
  isDefaultExpanded = _ref$isDefaultExpande === void 0 ? false : _ref$isDefaultExpande,
47
47
  onExpansionToggle = _ref.onExpansionToggle,
48
48
  children = _ref.children,
49
- dropIndicator = _ref.dropIndicator;
49
+ dropIndicator = _ref.dropIndicator,
50
+ testId = _ref.testId;
50
51
  var _useControlled = (0, _useControlled3.default)(isExpandedControlled, function () {
51
52
  return isDefaultExpanded;
52
53
  }),
@@ -60,7 +61,8 @@ var ExpandableMenuItem = exports.ExpandableMenuItem = /*#__PURE__*/(0, _react.fo
60
61
  }, /*#__PURE__*/React.createElement(_expandableMenuItemContext.OnExpansionToggleContext.Provider, {
61
62
  value: onExpansionToggle !== null && onExpansionToggle !== void 0 ? onExpansionToggle : null
62
63
  }, /*#__PURE__*/React.createElement(_menuListItem.MenuListItem, {
63
- ref: forwardedRef
64
+ ref: forwardedRef,
65
+ testId: testId
64
66
  }, /*#__PURE__*/React.createElement("div", {
65
67
  className: (0, _runtime.ax)([dropIndicator && relativeStyles.root])
66
68
  }, children, dropIndicator)))));
@@ -342,6 +342,15 @@ function SideNavInternal(_ref) {
342
342
  // Ignore if our element references are invalid
343
343
  return;
344
344
  }
345
+ if (!event.target.isConnected && (0, _platformFeatureFlags.fg)('platform_dst_nav4_side_nav_click_outside_fix')) {
346
+ /**
347
+ * If the element that was clicked is no longer in the document, we should not collapse the side nav.
348
+ * This can happen when the user clicks on a dropdown menu item (such as one used in a `...` More menu),
349
+ * as the dropdown menu will close after being clicked. By the time this event listener runs, the clicked
350
+ * element will no longer be in the document, so the check below for `sideNav.contains(event.target)` will fail.
351
+ */
352
+ return;
353
+ }
345
354
  if (sideNav.contains(event.target)) {
346
355
  // Clicks inside the side nav should not close it
347
356
  return;
@@ -35,7 +35,8 @@ export const ExpandableMenuItem = /*#__PURE__*/forwardRef(({
35
35
  isDefaultExpanded = false,
36
36
  onExpansionToggle,
37
37
  children,
38
- dropIndicator
38
+ dropIndicator,
39
+ testId
39
40
  }, forwardedRef) => {
40
41
  const [isExpanded, setIsExpanded] = useControlled(isExpandedControlled, () => isDefaultExpanded);
41
42
  return /*#__PURE__*/React.createElement(IsExpandedContext.Provider, {
@@ -45,7 +46,8 @@ export const ExpandableMenuItem = /*#__PURE__*/forwardRef(({
45
46
  }, /*#__PURE__*/React.createElement(OnExpansionToggleContext.Provider, {
46
47
  value: onExpansionToggle !== null && onExpansionToggle !== void 0 ? onExpansionToggle : null
47
48
  }, /*#__PURE__*/React.createElement(MenuListItem, {
48
- ref: forwardedRef
49
+ ref: forwardedRef,
50
+ testId: testId
49
51
  }, /*#__PURE__*/React.createElement("div", {
50
52
  className: ax([dropIndicator && relativeStyles.root])
51
53
  }, children, dropIndicator)))));
@@ -327,6 +327,15 @@ function SideNavInternal({
327
327
  // Ignore if our element references are invalid
328
328
  return;
329
329
  }
330
+ if (!event.target.isConnected && fg('platform_dst_nav4_side_nav_click_outside_fix')) {
331
+ /**
332
+ * If the element that was clicked is no longer in the document, we should not collapse the side nav.
333
+ * This can happen when the user clicks on a dropdown menu item (such as one used in a `...` More menu),
334
+ * as the dropdown menu will close after being clicked. By the time this event listener runs, the clicked
335
+ * element will no longer be in the document, so the check below for `sideNav.contains(event.target)` will fail.
336
+ */
337
+ return;
338
+ }
330
339
  if (sideNav.contains(event.target)) {
331
340
  // Clicks inside the side nav should not close it
332
341
  return;
@@ -37,7 +37,8 @@ export var ExpandableMenuItem = /*#__PURE__*/forwardRef(function (_ref, forwarde
37
37
  isDefaultExpanded = _ref$isDefaultExpande === void 0 ? false : _ref$isDefaultExpande,
38
38
  onExpansionToggle = _ref.onExpansionToggle,
39
39
  children = _ref.children,
40
- dropIndicator = _ref.dropIndicator;
40
+ dropIndicator = _ref.dropIndicator,
41
+ testId = _ref.testId;
41
42
  var _useControlled = useControlled(isExpandedControlled, function () {
42
43
  return isDefaultExpanded;
43
44
  }),
@@ -51,7 +52,8 @@ export var ExpandableMenuItem = /*#__PURE__*/forwardRef(function (_ref, forwarde
51
52
  }, /*#__PURE__*/React.createElement(OnExpansionToggleContext.Provider, {
52
53
  value: onExpansionToggle !== null && onExpansionToggle !== void 0 ? onExpansionToggle : null
53
54
  }, /*#__PURE__*/React.createElement(MenuListItem, {
54
- ref: forwardedRef
55
+ ref: forwardedRef,
56
+ testId: testId
55
57
  }, /*#__PURE__*/React.createElement("div", {
56
58
  className: ax([dropIndicator && relativeStyles.root])
57
59
  }, children, dropIndicator)))));
@@ -333,6 +333,15 @@ function SideNavInternal(_ref) {
333
333
  // Ignore if our element references are invalid
334
334
  return;
335
335
  }
336
+ if (!event.target.isConnected && fg('platform_dst_nav4_side_nav_click_outside_fix')) {
337
+ /**
338
+ * If the element that was clicked is no longer in the document, we should not collapse the side nav.
339
+ * This can happen when the user clicks on a dropdown menu item (such as one used in a `...` More menu),
340
+ * as the dropdown menu will close after being clicked. By the time this event listener runs, the clicked
341
+ * element will no longer be in the document, so the check below for `sideNav.contains(event.target)` will fail.
342
+ */
343
+ return;
344
+ }
336
345
  if (sideNav.contains(event.target)) {
337
346
  // Clicks inside the side nav should not close it
338
347
  return;
@@ -37,6 +37,10 @@ export type ExpandableMenuItemProps = {
37
37
  * and not when only the `ExpandableMenuItemTrigger` is a drop target.
38
38
  */
39
39
  dropIndicator?: ReactNode;
40
+ /**
41
+ * testId for MenuListItem
42
+ */
43
+ testId?: string;
40
44
  };
41
45
  /**
42
46
  * __ExpandableMenuItem__
@@ -37,6 +37,10 @@ export type ExpandableMenuItemProps = {
37
37
  * and not when only the `ExpandableMenuItemTrigger` is a drop target.
38
38
  */
39
39
  dropIndicator?: ReactNode;
40
+ /**
41
+ * testId for MenuListItem
42
+ */
43
+ testId?: string;
40
44
  };
41
45
  /**
42
46
  * __ExpandableMenuItem__
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/navigation-system",
3
- "version": "2.5.0",
3
+ "version": "2.6.1",
4
4
  "description": "The latest navigation system for Atlassian apps.",
5
5
  "repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
6
6
  "author": "Atlassian Pty Ltd",
@@ -184,6 +184,9 @@
184
184
  },
185
185
  "platform_dst_nav4_menu_section_heading_a11y": {
186
186
  "type": "boolean"
187
+ },
188
+ "platform_dst_nav4_side_nav_click_outside_fix": {
189
+ "type": "boolean"
187
190
  }
188
191
  },
189
192
  "homepage": "https://atlassian.design/components/navigation-system"