@atlaskit/help 9.2.2 → 9.3.0

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,24 @@
1
1
  # @atlaskit/help
2
2
 
3
+ ## 9.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`00e69e0b7c839`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/00e69e0b7c839) -
8
+ Clean up and removal of the `platform-visual-refresh-icons` feature flag.
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies
13
+
14
+ ## 9.2.3
15
+
16
+ ### Patch Changes
17
+
18
+ - [`b429c01ce6af9`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b429c01ce6af9) -
19
+ icon migration entry point update
20
+ - Updated dependencies
21
+
3
22
  ## 9.2.2
4
23
 
5
24
  ### Patch Changes
@@ -8,20 +8,13 @@ exports.IconWrapper = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _compiled = require("@atlaskit/primitives/compiled");
10
10
  var _icon = require("@atlaskit/icon");
11
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
12
11
  var IconWrapper = exports.IconWrapper = function IconWrapper(_ref) {
13
12
  var Icon = _ref.Icon,
14
13
  appearance = _ref.appearance;
15
14
  return /*#__PURE__*/_react.default.createElement(_compiled.Flex, {
16
15
  alignItems: "center",
17
16
  justifyContent: "center"
18
- }, !(0, _platformFeatureFlags.fg)('platform-visual-refresh-icons') ? /*#__PURE__*/_react.default.createElement(Icon, {
19
- label: "",
20
- color: "var(--ds-icon-inverse, #FFFFFF)"
21
- }) :
22
- /*#__PURE__*/
23
- // @ts-ignore
24
- _react.default.createElement(_icon.IconTile, {
17
+ }, /*#__PURE__*/_react.default.createElement(_icon.IconTile, {
25
18
  icon: Icon,
26
19
  size: "16",
27
20
  label: "",
@@ -9,7 +9,7 @@ var _react = _interopRequireDefault(require("react"));
9
9
  var _reactIntlNext = require("react-intl-next");
10
10
  var _analyticsNext = require("@atlaskit/analytics-next");
11
11
  var _reactTransitionGroup = require("react-transition-group");
12
- var _arrowLeft = _interopRequireDefault(require("@atlaskit/icon/core/migration/arrow-left"));
12
+ var _arrowLeft = _interopRequireDefault(require("@atlaskit/icon/core/arrow-left"));
13
13
  var _standardButton = _interopRequireDefault(require("@atlaskit/button/standard-button"));
14
14
  var _messages = require("../../messages");
15
15
  var _styled = require("../styled");
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.NeedMoreHelp = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
- var _lightbulb = _interopRequireDefault(require("@atlaskit/icon/core/migration/lightbulb"));
9
+ var _lightbulb = _interopRequireDefault(require("@atlaskit/icon/core/lightbulb"));
10
10
  var _compiled = require("@atlaskit/primitives/compiled");
11
11
  var _reactIntlNext = require("react-intl-next");
12
12
  var _styled = require("./styled");
@@ -9,7 +9,7 @@ exports.default = exports.WhatsNewButton = void 0;
9
9
  var _react = _interopRequireWildcard(require("react"));
10
10
  var _analyticsNext = require("@atlaskit/analytics-next");
11
11
  var colors = _interopRequireWildcard(require("@atlaskit/theme/colors"));
12
- var _lightbulb = _interopRequireDefault(require("@atlaskit/icon/core/migration/lightbulb"));
12
+ var _lightbulb = _interopRequireDefault(require("@atlaskit/icon/core/lightbulb"));
13
13
  var _reactIntlNext = require("react-intl-next");
14
14
  var _whatsNewArticleContext = require("../../contexts/whatsNewArticleContext");
15
15
  var _navigationContext = require("../../contexts/navigationContext");
@@ -101,14 +101,14 @@ var getCurrentArticleItemSlim = function getCurrentArticleItemSlim(history) {
101
101
  if (article) {
102
102
  if (type === _Help.ARTICLE_TYPE.HELP_ARTICLE) {
103
103
  var _ref = article,
104
- body = _ref.body,
105
- relatedArticles = _ref.relatedArticles,
104
+ _body = _ref.body,
105
+ _relatedArticles = _ref.relatedArticles,
106
106
  articleItemData = (0, _objectWithoutProperties2.default)(_ref, _excluded);
107
107
  var currentArticleSlimData = articleItemData;
108
108
  return currentArticleSlimData;
109
109
  } else if (type === _Help.ARTICLE_TYPE.WHATS_NEW) {
110
110
  var _ref2 = article,
111
- description = _ref2.description,
111
+ _description = _ref2.description,
112
112
  whatsNewArticleItemData = (0, _objectWithoutProperties2.default)(_ref2, _excluded2);
113
113
  var currentWhatsNewArticleSlimData = whatsNewArticleItemData;
114
114
  return currentWhatsNewArticleSlimData;
@@ -274,6 +274,9 @@ var NavigationContextProvider = exports.NavigationContextProvider = function Nav
274
274
  var onGetHelpArticleRef = (0, _react.useRef)(onGetHelpArticle);
275
275
  var onGetWhatsNewArticleRef = (0, _react.useRef)(onGetWhatsNewArticle);
276
276
 
277
+ // Ref to store triggering elements for focus restoration on navigate back
278
+ var triggerElementsRef = (0, _react.useRef)([]);
279
+
277
280
  // Update refs when functions change
278
281
  onGetHelpArticleRef.current = onGetHelpArticle;
279
282
  onGetWhatsNewArticleRef.current = onGetWhatsNewArticle;
@@ -376,7 +379,7 @@ var NavigationContextProvider = exports.NavigationContextProvider = function Nav
376
379
  };
377
380
  }(), []);
378
381
  var navigateBack = (0, _react.useCallback)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
379
- var _searchResult$length;
382
+ var triggerElement, _searchResult$length, timeoutId;
380
383
  return _regenerator.default.wrap(function _callee3$(_context3) {
381
384
  while (1) switch (_context3.prev = _context3.next) {
382
385
  case 0:
@@ -397,31 +400,48 @@ var NavigationContextProvider = exports.NavigationContextProvider = function Nav
397
400
  });
398
401
  return _context3.abrupt("return");
399
402
  case 8:
400
- // if the history is not empty and ...
401
- if (currentHistory.length > 0) {
402
- // the history has more than one article, navigate back through the history
403
- if (currentHistory.length > 1) {
404
- // Remove last element
403
+ if (!(currentHistory.length > 0)) {
404
+ _context3.next = 14;
405
+ break;
406
+ }
407
+ // Pop the trigger element before navigating back
408
+ triggerElement = triggerElementsRef.current.pop(); // the history has more than one article, navigate back through the history
409
+ if (currentHistory.length > 1) {
410
+ // Remove last element
411
+ dispatchNavigationAction({
412
+ type: 'removeLastHistoryItem'
413
+ });
414
+ } else if (currentHistory.length === 1) {
415
+ // If the search value is not empty and search result is not empty, show the search results
416
+ if (searchValue !== '' && ((_searchResult$length = searchResult === null || searchResult === void 0 ? void 0 : searchResult.length) !== null && _searchResult$length !== void 0 ? _searchResult$length : 0) > 0 && onSearch !== undefined) {
417
+ dispatchNavigationAction({
418
+ type: 'updateView',
419
+ payload: _constants.VIEW.SEARCH
420
+ });
421
+ }
422
+ // If the search value is empty, show the default content
423
+ else {
405
424
  dispatchNavigationAction({
406
- type: 'removeLastHistoryItem'
425
+ type: 'removeAllHistoryItems'
407
426
  });
408
- } else if (currentHistory.length === 1) {
409
- // If the search value is not empty and search result is not empty, show the search results
410
- if (searchValue !== '' && ((_searchResult$length = searchResult === null || searchResult === void 0 ? void 0 : searchResult.length) !== null && _searchResult$length !== void 0 ? _searchResult$length : 0) > 0 && onSearch !== undefined) {
411
- dispatchNavigationAction({
412
- type: 'updateView',
413
- payload: _constants.VIEW.SEARCH
414
- });
415
- }
416
- // If the search value is empty, show the default content
417
- else {
418
- dispatchNavigationAction({
419
- type: 'removeAllHistoryItems'
420
- });
421
- }
422
427
  }
423
428
  }
424
- case 9:
429
+
430
+ // Restore focus to the element that triggered the navigation
431
+ if (!triggerElement) {
432
+ _context3.next = 14;
433
+ break;
434
+ }
435
+ // Wait for slide-out animation to complete (300ms) plus a buffer
436
+ timeoutId = setTimeout(function () {
437
+ if (document.body.contains(triggerElement)) {
438
+ triggerElement.focus();
439
+ }
440
+ }, 400); // Increased from 350ms to 400ms
441
+ return _context3.abrupt("return", function () {
442
+ return clearTimeout(timeoutId);
443
+ });
444
+ case 14:
425
445
  case "end":
426
446
  return _context3.stop();
427
447
  }
@@ -429,6 +449,8 @@ var NavigationContextProvider = exports.NavigationContextProvider = function Nav
429
449
  })), [currentView, searchValue, currentArticleId, currentHistory, onSearch, searchResult === null || searchResult === void 0 ? void 0 : searchResult.length]);
430
450
  var onClose = (0, _react.useCallback)(function (event, analyticsEvent) {
431
451
  if (onCloseButtonClick) {
452
+ // Clear trigger elements stack when closing
453
+ triggerElementsRef.current = [];
432
454
  dispatchNavigationAction({
433
455
  type: 'removeAllHistoryItems'
434
456
  });
@@ -436,6 +458,11 @@ var NavigationContextProvider = exports.NavigationContextProvider = function Nav
436
458
  }
437
459
  }, [onCloseButtonClick]);
438
460
  var onOpenArticle = (0, _react.useCallback)(function (newArticleId) {
461
+ // Capture the currently focused element before opening article
462
+ var triggerElement = document.activeElement;
463
+ if (triggerElement && triggerElement !== document.body) {
464
+ triggerElementsRef.current.push(triggerElement);
465
+ }
439
466
  dispatchNavigationAction({
440
467
  type: 'addNewHistoryItem',
441
468
  payload: newArticleId
@@ -475,7 +502,12 @@ var NavigationContextProvider = exports.NavigationContextProvider = function Nav
475
502
  } else {
476
503
  /**
477
504
  * Otherwise we need to add a new article
505
+ * Capture the focused element for focus restoration when navigating back
478
506
  */
507
+ var triggerElement = document.activeElement;
508
+ if (triggerElement && triggerElement !== document.body && propsArticleId.id !== '') {
509
+ triggerElementsRef.current.push(triggerElement);
510
+ }
479
511
  dispatchNavigationAction({
480
512
  type: 'newArticle',
481
513
  payload: propsArticleId
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
2
  import { Flex } from '@atlaskit/primitives/compiled';
3
3
  import { IconTile } from '@atlaskit/icon';
4
- import { fg } from '@atlaskit/platform-feature-flags';
5
4
  export const IconWrapper = ({
6
5
  Icon,
7
6
  appearance
@@ -9,13 +8,7 @@ export const IconWrapper = ({
9
8
  return /*#__PURE__*/React.createElement(Flex, {
10
9
  alignItems: "center",
11
10
  justifyContent: "center"
12
- }, !fg('platform-visual-refresh-icons') ? /*#__PURE__*/React.createElement(Icon, {
13
- label: "",
14
- color: "var(--ds-icon-inverse, #FFFFFF)"
15
- }) :
16
- /*#__PURE__*/
17
- // @ts-ignore
18
- React.createElement(IconTile, {
11
+ }, /*#__PURE__*/React.createElement(IconTile, {
19
12
  icon: Icon,
20
13
  size: "16",
21
14
  label: "",
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { injectIntl } from 'react-intl-next';
3
3
  import { useAnalyticsEvents, AnalyticsContext } from '@atlaskit/analytics-next';
4
4
  import { Transition } from 'react-transition-group';
5
- import ArrowleftIcon from '@atlaskit/icon/core/migration/arrow-left';
5
+ import ArrowleftIcon from '@atlaskit/icon/core/arrow-left';
6
6
  import Button from '@atlaskit/button/standard-button';
7
7
  import { messages } from '../../messages';
8
8
  import { BackButtonContainer, BACK_BUTTON_CONTAINER_TRANSITION_DURATION_MS } from '../styled';
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import LightbulbIcon from '@atlaskit/icon/core/migration/lightbulb';
2
+ import LightbulbIcon from '@atlaskit/icon/core/lightbulb';
3
3
  import { Inline } from '@atlaskit/primitives/compiled';
4
4
  import { useIntl } from 'react-intl-next';
5
5
  import { NeedMoreHelpContainer, NeedMoreHelpContent, HelpAskAI } from './styled';
@@ -1,7 +1,7 @@
1
1
  import React, { useCallback } from 'react';
2
2
  import { AnalyticsContext } from '@atlaskit/analytics-next';
3
3
  import * as colors from '@atlaskit/theme/colors';
4
- import LightbulbIcon from '@atlaskit/icon/core/migration/lightbulb';
4
+ import LightbulbIcon from '@atlaskit/icon/core/lightbulb';
5
5
  import { injectIntl } from 'react-intl-next';
6
6
  import { useWhatsNewArticleContext } from '../../contexts/whatsNewArticleContext';
7
7
  import { useNavigationContext } from '../../contexts/navigationContext';
@@ -81,15 +81,15 @@ const getCurrentArticleItemSlim = history => {
81
81
  if (article) {
82
82
  if (type === ARTICLE_TYPE.HELP_ARTICLE) {
83
83
  const {
84
- body,
85
- relatedArticles,
84
+ body: _body,
85
+ relatedArticles: _relatedArticles,
86
86
  ...articleItemData
87
87
  } = article;
88
88
  const currentArticleSlimData = articleItemData;
89
89
  return currentArticleSlimData;
90
90
  } else if (type === ARTICLE_TYPE.WHATS_NEW) {
91
91
  const {
92
- description,
92
+ description: _description,
93
93
  ...whatsNewArticleItemData
94
94
  } = article;
95
95
  const currentWhatsNewArticleSlimData = whatsNewArticleItemData;
@@ -273,6 +273,9 @@ export const NavigationContextProvider = ({
273
273
  const onGetHelpArticleRef = useRef(onGetHelpArticle);
274
274
  const onGetWhatsNewArticleRef = useRef(onGetWhatsNewArticle);
275
275
 
276
+ // Ref to store triggering elements for focus restoration on navigate back
277
+ const triggerElementsRef = useRef([]);
278
+
276
279
  // Update refs when functions change
277
280
  onGetHelpArticleRef.current = onGetHelpArticle;
278
281
  onGetWhatsNewArticleRef.current = onGetWhatsNewArticle;
@@ -312,7 +315,7 @@ export const NavigationContextProvider = ({
312
315
  }),
313
316
  state: REQUEST_STATE.done
314
317
  };
315
- } catch (error) {
318
+ } catch {
316
319
  return {
317
320
  ...historyItem,
318
321
  state: REQUEST_STATE.error
@@ -354,6 +357,9 @@ export const NavigationContextProvider = ({
354
357
 
355
358
  // if the history is not empty and ...
356
359
  if (currentHistory.length > 0) {
360
+ // Pop the trigger element before navigating back
361
+ const triggerElement = triggerElementsRef.current.pop();
362
+
357
363
  // the history has more than one article, navigate back through the history
358
364
  if (currentHistory.length > 1) {
359
365
  // Remove last element
@@ -376,10 +382,23 @@ export const NavigationContextProvider = ({
376
382
  });
377
383
  }
378
384
  }
385
+
386
+ // Restore focus to the element that triggered the navigation
387
+ if (triggerElement) {
388
+ // Wait for slide-out animation to complete (300ms) plus a buffer
389
+ const timeoutId = setTimeout(() => {
390
+ if (document.body.contains(triggerElement)) {
391
+ triggerElement.focus();
392
+ }
393
+ }, 400); // Increased from 350ms to 400ms
394
+ return () => clearTimeout(timeoutId);
395
+ }
379
396
  }
380
397
  }, [currentView, searchValue, currentArticleId, currentHistory, onSearch, searchResult === null || searchResult === void 0 ? void 0 : searchResult.length]);
381
398
  const onClose = useCallback((event, analyticsEvent) => {
382
399
  if (onCloseButtonClick) {
400
+ // Clear trigger elements stack when closing
401
+ triggerElementsRef.current = [];
383
402
  dispatchNavigationAction({
384
403
  type: 'removeAllHistoryItems'
385
404
  });
@@ -387,6 +406,11 @@ export const NavigationContextProvider = ({
387
406
  }
388
407
  }, [onCloseButtonClick]);
389
408
  const onOpenArticle = useCallback(newArticleId => {
409
+ // Capture the currently focused element before opening article
410
+ const triggerElement = document.activeElement;
411
+ if (triggerElement && triggerElement !== document.body) {
412
+ triggerElementsRef.current.push(triggerElement);
413
+ }
390
414
  dispatchNavigationAction({
391
415
  type: 'addNewHistoryItem',
392
416
  payload: newArticleId
@@ -426,7 +450,12 @@ export const NavigationContextProvider = ({
426
450
  } else {
427
451
  /**
428
452
  * Otherwise we need to add a new article
453
+ * Capture the focused element for focus restoration when navigating back
429
454
  */
455
+ const triggerElement = document.activeElement;
456
+ if (triggerElement && triggerElement !== document.body && propsArticleId.id !== '') {
457
+ triggerElementsRef.current.push(triggerElement);
458
+ }
430
459
  dispatchNavigationAction({
431
460
  type: 'newArticle',
432
461
  payload: propsArticleId
@@ -1,20 +1,13 @@
1
1
  import React from 'react';
2
2
  import { Flex } from '@atlaskit/primitives/compiled';
3
3
  import { IconTile } from '@atlaskit/icon';
4
- import { fg } from '@atlaskit/platform-feature-flags';
5
4
  export var IconWrapper = function IconWrapper(_ref) {
6
5
  var Icon = _ref.Icon,
7
6
  appearance = _ref.appearance;
8
7
  return /*#__PURE__*/React.createElement(Flex, {
9
8
  alignItems: "center",
10
9
  justifyContent: "center"
11
- }, !fg('platform-visual-refresh-icons') ? /*#__PURE__*/React.createElement(Icon, {
12
- label: "",
13
- color: "var(--ds-icon-inverse, #FFFFFF)"
14
- }) :
15
- /*#__PURE__*/
16
- // @ts-ignore
17
- React.createElement(IconTile, {
10
+ }, /*#__PURE__*/React.createElement(IconTile, {
18
11
  icon: Icon,
19
12
  size: "16",
20
13
  label: "",
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { injectIntl } from 'react-intl-next';
3
3
  import { useAnalyticsEvents, AnalyticsContext } from '@atlaskit/analytics-next';
4
4
  import { Transition } from 'react-transition-group';
5
- import ArrowleftIcon from '@atlaskit/icon/core/migration/arrow-left';
5
+ import ArrowleftIcon from '@atlaskit/icon/core/arrow-left';
6
6
  import Button from '@atlaskit/button/standard-button';
7
7
  import { messages } from '../../messages';
8
8
  import { BackButtonContainer, BACK_BUTTON_CONTAINER_TRANSITION_DURATION_MS } from '../styled';
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import LightbulbIcon from '@atlaskit/icon/core/migration/lightbulb';
2
+ import LightbulbIcon from '@atlaskit/icon/core/lightbulb';
3
3
  import { Inline } from '@atlaskit/primitives/compiled';
4
4
  import { useIntl } from 'react-intl-next';
5
5
  import { NeedMoreHelpContainer, NeedMoreHelpContent, HelpAskAI } from './styled';
@@ -1,7 +1,7 @@
1
1
  import React, { useCallback } from 'react';
2
2
  import { AnalyticsContext } from '@atlaskit/analytics-next';
3
3
  import * as colors from '@atlaskit/theme/colors';
4
- import LightbulbIcon from '@atlaskit/icon/core/migration/lightbulb';
4
+ import LightbulbIcon from '@atlaskit/icon/core/lightbulb';
5
5
  import { injectIntl } from 'react-intl-next';
6
6
  import { useWhatsNewArticleContext } from '../../contexts/whatsNewArticleContext';
7
7
  import { useNavigationContext } from '../../contexts/navigationContext';
@@ -92,14 +92,14 @@ var getCurrentArticleItemSlim = function getCurrentArticleItemSlim(history) {
92
92
  if (article) {
93
93
  if (type === ARTICLE_TYPE.HELP_ARTICLE) {
94
94
  var _ref = article,
95
- body = _ref.body,
96
- relatedArticles = _ref.relatedArticles,
95
+ _body = _ref.body,
96
+ _relatedArticles = _ref.relatedArticles,
97
97
  articleItemData = _objectWithoutProperties(_ref, _excluded);
98
98
  var currentArticleSlimData = articleItemData;
99
99
  return currentArticleSlimData;
100
100
  } else if (type === ARTICLE_TYPE.WHATS_NEW) {
101
101
  var _ref2 = article,
102
- description = _ref2.description,
102
+ _description = _ref2.description,
103
103
  whatsNewArticleItemData = _objectWithoutProperties(_ref2, _excluded2);
104
104
  var currentWhatsNewArticleSlimData = whatsNewArticleItemData;
105
105
  return currentWhatsNewArticleSlimData;
@@ -265,6 +265,9 @@ export var NavigationContextProvider = function NavigationContextProvider(_ref4)
265
265
  var onGetHelpArticleRef = useRef(onGetHelpArticle);
266
266
  var onGetWhatsNewArticleRef = useRef(onGetWhatsNewArticle);
267
267
 
268
+ // Ref to store triggering elements for focus restoration on navigate back
269
+ var triggerElementsRef = useRef([]);
270
+
268
271
  // Update refs when functions change
269
272
  onGetHelpArticleRef.current = onGetHelpArticle;
270
273
  onGetWhatsNewArticleRef.current = onGetWhatsNewArticle;
@@ -367,7 +370,7 @@ export var NavigationContextProvider = function NavigationContextProvider(_ref4)
367
370
  };
368
371
  }(), []);
369
372
  var navigateBack = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
370
- var _searchResult$length;
373
+ var triggerElement, _searchResult$length, timeoutId;
371
374
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
372
375
  while (1) switch (_context3.prev = _context3.next) {
373
376
  case 0:
@@ -388,31 +391,48 @@ export var NavigationContextProvider = function NavigationContextProvider(_ref4)
388
391
  });
389
392
  return _context3.abrupt("return");
390
393
  case 8:
391
- // if the history is not empty and ...
392
- if (currentHistory.length > 0) {
393
- // the history has more than one article, navigate back through the history
394
- if (currentHistory.length > 1) {
395
- // Remove last element
394
+ if (!(currentHistory.length > 0)) {
395
+ _context3.next = 14;
396
+ break;
397
+ }
398
+ // Pop the trigger element before navigating back
399
+ triggerElement = triggerElementsRef.current.pop(); // the history has more than one article, navigate back through the history
400
+ if (currentHistory.length > 1) {
401
+ // Remove last element
402
+ dispatchNavigationAction({
403
+ type: 'removeLastHistoryItem'
404
+ });
405
+ } else if (currentHistory.length === 1) {
406
+ // If the search value is not empty and search result is not empty, show the search results
407
+ if (searchValue !== '' && ((_searchResult$length = searchResult === null || searchResult === void 0 ? void 0 : searchResult.length) !== null && _searchResult$length !== void 0 ? _searchResult$length : 0) > 0 && onSearch !== undefined) {
408
+ dispatchNavigationAction({
409
+ type: 'updateView',
410
+ payload: VIEW.SEARCH
411
+ });
412
+ }
413
+ // If the search value is empty, show the default content
414
+ else {
396
415
  dispatchNavigationAction({
397
- type: 'removeLastHistoryItem'
416
+ type: 'removeAllHistoryItems'
398
417
  });
399
- } else if (currentHistory.length === 1) {
400
- // If the search value is not empty and search result is not empty, show the search results
401
- if (searchValue !== '' && ((_searchResult$length = searchResult === null || searchResult === void 0 ? void 0 : searchResult.length) !== null && _searchResult$length !== void 0 ? _searchResult$length : 0) > 0 && onSearch !== undefined) {
402
- dispatchNavigationAction({
403
- type: 'updateView',
404
- payload: VIEW.SEARCH
405
- });
406
- }
407
- // If the search value is empty, show the default content
408
- else {
409
- dispatchNavigationAction({
410
- type: 'removeAllHistoryItems'
411
- });
412
- }
413
418
  }
414
419
  }
415
- case 9:
420
+
421
+ // Restore focus to the element that triggered the navigation
422
+ if (!triggerElement) {
423
+ _context3.next = 14;
424
+ break;
425
+ }
426
+ // Wait for slide-out animation to complete (300ms) plus a buffer
427
+ timeoutId = setTimeout(function () {
428
+ if (document.body.contains(triggerElement)) {
429
+ triggerElement.focus();
430
+ }
431
+ }, 400); // Increased from 350ms to 400ms
432
+ return _context3.abrupt("return", function () {
433
+ return clearTimeout(timeoutId);
434
+ });
435
+ case 14:
416
436
  case "end":
417
437
  return _context3.stop();
418
438
  }
@@ -420,6 +440,8 @@ export var NavigationContextProvider = function NavigationContextProvider(_ref4)
420
440
  })), [currentView, searchValue, currentArticleId, currentHistory, onSearch, searchResult === null || searchResult === void 0 ? void 0 : searchResult.length]);
421
441
  var onClose = useCallback(function (event, analyticsEvent) {
422
442
  if (onCloseButtonClick) {
443
+ // Clear trigger elements stack when closing
444
+ triggerElementsRef.current = [];
423
445
  dispatchNavigationAction({
424
446
  type: 'removeAllHistoryItems'
425
447
  });
@@ -427,6 +449,11 @@ export var NavigationContextProvider = function NavigationContextProvider(_ref4)
427
449
  }
428
450
  }, [onCloseButtonClick]);
429
451
  var onOpenArticle = useCallback(function (newArticleId) {
452
+ // Capture the currently focused element before opening article
453
+ var triggerElement = document.activeElement;
454
+ if (triggerElement && triggerElement !== document.body) {
455
+ triggerElementsRef.current.push(triggerElement);
456
+ }
430
457
  dispatchNavigationAction({
431
458
  type: 'addNewHistoryItem',
432
459
  payload: newArticleId
@@ -466,7 +493,12 @@ export var NavigationContextProvider = function NavigationContextProvider(_ref4)
466
493
  } else {
467
494
  /**
468
495
  * Otherwise we need to add a new article
496
+ * Capture the focused element for focus restoration when navigating back
469
497
  */
498
+ var triggerElement = document.activeElement;
499
+ if (triggerElement && triggerElement !== document.body && propsArticleId.id !== '') {
500
+ triggerElementsRef.current.push(triggerElement);
501
+ }
470
502
  dispatchNavigationAction({
471
503
  type: 'newArticle',
472
504
  payload: propsArticleId
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/help",
3
- "version": "9.2.2",
3
+ "version": "9.3.0",
4
4
  "description": "A cross-product help component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -33,8 +33,8 @@
33
33
  "dependencies": {
34
34
  "@atlaskit/analytics-next": "^11.1.0",
35
35
  "@atlaskit/button": "^23.9.0",
36
- "@atlaskit/checkbox": "^17.2.0",
37
- "@atlaskit/form": "^15.1.0",
36
+ "@atlaskit/checkbox": "^17.3.0",
37
+ "@atlaskit/form": "^15.2.0",
38
38
  "@atlaskit/heading": "^5.2.0",
39
39
  "@atlaskit/help-article": "^6.0.0",
40
40
  "@atlaskit/help-layout": "^6.3.0",
@@ -43,7 +43,7 @@
43
43
  "@atlaskit/notification-log-client": "^6.4.0",
44
44
  "@atlaskit/platform-feature-flags": "^1.1.0",
45
45
  "@atlaskit/primitives": "^17.0.0",
46
- "@atlaskit/radio": "^8.3.0",
46
+ "@atlaskit/radio": "^8.4.0",
47
47
  "@atlaskit/section-message": "^8.11.0",
48
48
  "@atlaskit/select": "^21.6.0",
49
49
  "@atlaskit/spinner": "^19.0.0",