@atlaskit/help 6.0.7 → 7.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.
Files changed (32) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/cjs/components/Article/HelpArticle/index.js +6 -8
  3. package/dist/cjs/components/Article/index.js +2 -2
  4. package/dist/cjs/components/Help.js +3 -1
  5. package/dist/cjs/components/Search/SearchResults/index.js +8 -11
  6. package/dist/cjs/components/WhatsNew/WhatsNewButton/index.js +6 -8
  7. package/dist/cjs/components/WhatsNew/WhatsNewResults/WhatsNewResultsList/WhatsNewResultsList.js +1 -1
  8. package/dist/cjs/components/WhatsNew/WhatsNewResults/WhatsNewResultsList/index.js +6 -8
  9. package/dist/cjs/components/WhatsNew/WhatsNewResults/index.js +33 -6
  10. package/dist/cjs/components/contexts/navigationContext.js +111 -50
  11. package/dist/cjs/version.json +1 -1
  12. package/dist/es2019/components/Article/HelpArticle/index.js +6 -8
  13. package/dist/es2019/components/Search/SearchResults/index.js +6 -9
  14. package/dist/es2019/components/WhatsNew/WhatsNewButton/index.js +6 -8
  15. package/dist/es2019/components/WhatsNew/WhatsNewResults/WhatsNewResultsList/WhatsNewResultsList.js +1 -1
  16. package/dist/es2019/components/WhatsNew/WhatsNewResults/WhatsNewResultsList/index.js +6 -8
  17. package/dist/es2019/components/WhatsNew/WhatsNewResults/index.js +31 -5
  18. package/dist/es2019/components/contexts/navigationContext.js +99 -39
  19. package/dist/es2019/version.json +1 -1
  20. package/dist/esm/components/Article/HelpArticle/index.js +6 -8
  21. package/dist/esm/components/Article/index.js +2 -2
  22. package/dist/esm/components/Help.js +2 -1
  23. package/dist/esm/components/Search/SearchResults/index.js +8 -11
  24. package/dist/esm/components/WhatsNew/WhatsNewButton/index.js +6 -8
  25. package/dist/esm/components/WhatsNew/WhatsNewResults/WhatsNewResultsList/WhatsNewResultsList.js +1 -1
  26. package/dist/esm/components/WhatsNew/WhatsNewResults/WhatsNewResultsList/index.js +6 -8
  27. package/dist/esm/components/WhatsNew/WhatsNewResults/index.js +33 -7
  28. package/dist/esm/components/contexts/navigationContext.js +108 -50
  29. package/dist/esm/version.json +1 -1
  30. package/dist/types/components/contexts/navigationContext.d.ts +12 -7
  31. package/dist/types/model/Help.d.ts +8 -4
  32. package/package.json +5 -5
@@ -25,20 +25,18 @@ export const WhatsNewButton = ({
25
25
  whatsNewGetNotificationProvider
26
26
  } = useWhatsNewArticleContext();
27
27
  const {
28
- setArticleId
28
+ openArticle
29
29
  } = useNavigationContext();
30
30
  const handleOnButtonClick = useCallback((id, analytics, event) => {
31
31
  if (onWhatsNewButtonClick) {
32
32
  onWhatsNewButtonClick(event, analytics);
33
33
  }
34
34
 
35
- if (setArticleId) {
36
- setArticleId({
37
- id: '',
38
- type: ARTICLE_TYPE.WHATS_NEW
39
- });
40
- }
41
- }, [onWhatsNewButtonClick, setArticleId]);
35
+ openArticle({
36
+ id: '',
37
+ type: ARTICLE_TYPE.WHATS_NEW
38
+ });
39
+ }, [onWhatsNewButtonClick, openArticle]);
42
40
  return /*#__PURE__*/React.createElement(HelpContentButton, {
43
41
  id: "whats-new",
44
42
  key: "whats-new",
@@ -20,7 +20,7 @@ const WhatsNewResultsList = ({
20
20
  const featureRolloutDateString = whatsNewArticle === null || whatsNewArticle === void 0 ? void 0 : whatsNewArticle.featureRolloutDate;
21
21
 
22
22
  if (featureRolloutDateString) {
23
- const featureRolloutDateArray = featureRolloutDateString.replace('-', '/');
23
+ const featureRolloutDateArray = featureRolloutDateString.replace('/-/g', '/');
24
24
  const featureRolloutDate = toDate(new Date(featureRolloutDateArray));
25
25
 
26
26
  if (whatsNewArticlesGroupedByDateTemp[featureRolloutDateString]) {
@@ -29,7 +29,7 @@ const WhatsNewResultsList = ({
29
29
  onShowMoreButtonClick
30
30
  }) => {
31
31
  const {
32
- setArticleId
32
+ openArticle
33
33
  } = useNavigationContext();
34
34
 
35
35
  const handleShowMoreButtonClick = (event, analyticsEvent) => {
@@ -39,17 +39,15 @@ const WhatsNewResultsList = ({
39
39
  };
40
40
 
41
41
  const handleOnWhatsNewResultItemClick = useCallback((event, analyticsEvent, articleData) => {
42
- if (setArticleId) {
43
- setArticleId({
44
- id: articleData.id,
45
- type: ARTICLE_TYPE.WHATS_NEW
46
- });
47
- }
42
+ openArticle({
43
+ id: articleData.id,
44
+ type: ARTICLE_TYPE.WHATS_NEW
45
+ });
48
46
 
49
47
  if (onWhatsNewResultItemClick) {
50
48
  onWhatsNewResultItemClick(event, analyticsEvent, articleData);
51
49
  }
52
- }, [onWhatsNewResultItemClick, setArticleId]);
50
+ }, [onWhatsNewResultItemClick, openArticle]);
53
51
  return whatsNewArticles && whatsNewArticles.length > 0 ? /*#__PURE__*/React.createElement(WhatsNewResultsListContainer, null, /*#__PURE__*/React.createElement(ThemeProvider, {
54
52
  theme: {
55
53
  [itemThemeNamespace]: ITEM_THEME
@@ -1,5 +1,6 @@
1
- import React, { useCallback, useState } from 'react';
1
+ import React, { useCallback, useState, useRef } from 'react';
2
2
  import { Transition } from 'react-transition-group';
3
+ import isEqual from 'lodash/isEqual';
3
4
  import Select from '@atlaskit/select';
4
5
  import { injectIntl } from 'react-intl-next';
5
6
  import { VIEW } from '../../constants';
@@ -51,11 +52,17 @@ export const WhatsNewResults = ({
51
52
  searchWhatsNewArticlesState,
52
53
  onWhatsNewResultItemClick
53
54
  } = useWhatsNewArticleContext();
55
+ const containerRef = useRef(null);
56
+ const containerScrollPosition = useRef(0);
54
57
  const SELECT_DEFAULT_VALUE = {
55
58
  value: '',
56
59
  label: formatMessage(messages.help_whats_new_filter_select_option_all)
57
60
  };
58
- const [selectedOption, setSelectedOption] = useState(SELECT_DEFAULT_VALUE);
61
+ const SELECT_EMPTY_VALUE = {
62
+ value: undefined,
63
+ label: ''
64
+ };
65
+ const [selectedOption, setSelectedOption] = useState(SELECT_EMPTY_VALUE);
59
66
  const handleOnShowMoreButtonClick = useCallback(() => {
60
67
  if (searchWhatsNewArticlesResult && onSearchWhatsNewArticles) {
61
68
  const {
@@ -70,8 +77,25 @@ export const WhatsNewResults = ({
70
77
  }, [onSearchWhatsNewArticles, searchWhatsNewArticlesResult, selectedOption]);
71
78
 
72
79
  const handleOnEnter = () => {
73
- setSelectedOption(SELECT_DEFAULT_VALUE);
74
- onSearchWhatsNewArticles && onSearchWhatsNewArticles();
80
+ setTimeout(() => {
81
+ if (containerRef.current) {
82
+ containerRef.current.scrollTop = containerScrollPosition.current;
83
+ }
84
+ }, 0);
85
+
86
+ if (isEqual(selectedOption, SELECT_EMPTY_VALUE)) {
87
+ setSelectedOption(SELECT_DEFAULT_VALUE);
88
+ onSearchWhatsNewArticles && onSearchWhatsNewArticles();
89
+ }
90
+ };
91
+
92
+ const handleOnExit = () => {
93
+ if (helpContextView === VIEW.DEFAULT_CONTENT) {
94
+ setSelectedOption(SELECT_EMPTY_VALUE);
95
+ containerScrollPosition.current = 0;
96
+ } else {
97
+ containerScrollPosition.current = containerRef.current ? containerRef.current.scrollTop : 0;
98
+ }
75
99
  };
76
100
 
77
101
  const handleOnClearFilter = () => {
@@ -87,8 +111,10 @@ export const WhatsNewResults = ({
87
111
  return /*#__PURE__*/React.createElement(Transition, {
88
112
  in: helpContextView === VIEW.WHATS_NEW,
89
113
  timeout: FADEIN_OVERLAY_TRANSITION_DURATION_MS,
90
- onEnter: handleOnEnter
114
+ onEnter: handleOnEnter,
115
+ onExit: handleOnExit
91
116
  }, state => /*#__PURE__*/React.createElement(WhatsNewResultsContainer, {
117
+ ref: containerRef,
92
118
  style: { ...defaultStyle,
93
119
  ...transitionStyles[state]
94
120
  }
@@ -1,4 +1,5 @@
1
1
  import React, { useReducer, useEffect, useCallback, useMemo } from 'react';
2
+ import isEqual from 'lodash/isEqual';
2
3
  import { REQUEST_STATE } from '../../model/Requests';
3
4
  import { ARTICLE_TYPE } from '../../model/Help';
4
5
  import { createCtx } from '../../util/hooks/ctx';
@@ -8,6 +9,10 @@ import { useWhatsNewArticleContext } from './whatsNewArticleContext';
8
9
  import { useHomeContext } from './homeContext';
9
10
  import { useSearchContext } from './searchContext';
10
11
  import { useHeaderContext } from './headerContext';
12
+ const DEFAULT_ARTICLE_ID = {
13
+ id: '',
14
+ type: ARTICLE_TYPE.HELP_ARTICLE
15
+ };
11
16
  export const [useNavigationContext, CtxProvider] = createCtx();
12
17
 
13
18
  const getNewHistoryItem = (id, type) => {
@@ -39,6 +44,21 @@ const getSimpleHistory = history => history.map(historyItem => {
39
44
  type
40
45
  };
41
46
  });
47
+ /**
48
+ * Get history data (list of IDs and UID)
49
+ */
50
+
51
+
52
+ const getHistoryData = history => history.map(historyItem => {
53
+ const {
54
+ id,
55
+ uid
56
+ } = historyItem;
57
+ return {
58
+ id,
59
+ uid
60
+ };
61
+ });
42
62
  /**
43
63
  * Get the last article in the history
44
64
  */
@@ -111,10 +131,28 @@ const navigationReducer = ({
111
131
  const {
112
132
  payload: newArticleId
113
133
  } = action;
134
+
135
+ if (isEqual(newArticleId, DEFAULT_ARTICLE_ID)) {
136
+ newState = {
137
+ articleId: newArticleId,
138
+ history: [],
139
+ view: VIEW.DEFAULT_CONTENT
140
+ };
141
+ } else {
142
+ newState = {
143
+ articleId: newArticleId,
144
+ history: [...currentHistory, getNewHistoryItem(newArticleId.id, newArticleId.type)],
145
+ view: getViewForArticleId(newArticleId)
146
+ };
147
+ }
148
+ } else if (action.type === 'addNewHistoryItem' && action.payload) {
149
+ const {
150
+ payload: newArticleId
151
+ } = action;
114
152
  newState = {
115
- articleId: newArticleId,
153
+ articleId: currentArticleId,
116
154
  history: [...currentHistory, getNewHistoryItem(newArticleId.id, newArticleId.type)],
117
- view: getViewForArticleId(newArticleId)
155
+ view: getViewForArticleId(currentArticleId)
118
156
  };
119
157
  } else if (action.type === 'updateHistoryItem' && action.payload) {
120
158
  const {
@@ -175,13 +213,11 @@ const navigationReducer = ({
175
213
  };
176
214
 
177
215
  export const NavigationContextProvider = ({
178
- articleId: propsArticleId = {
179
- id: '',
180
- type: ARTICLE_TYPE.HELP_ARTICLE
216
+ navigationData = {
217
+ articleId: DEFAULT_ARTICLE_ID,
218
+ history: []
181
219
  },
182
- articleIdSetter,
183
- history: propsHistory = [],
184
- historySetter,
220
+ setNavigationData,
185
221
  children
186
222
  }) => {
187
223
  const {
@@ -202,13 +238,17 @@ export const NavigationContextProvider = ({
202
238
  const {
203
239
  onCloseButtonClick
204
240
  } = useHeaderContext();
241
+ const {
242
+ articleId: propsArticleId,
243
+ history: propsHistory
244
+ } = navigationData;
205
245
  const [{
206
246
  articleId: currentArticleId,
207
247
  history: currentHistory,
208
248
  view: currentView
209
249
  }, dispatchNavigationAction] = useReducer(navigationReducer, {
210
250
  articleId: propsArticleId,
211
- history: propsHistory,
251
+ history: !isEqual(propsArticleId, DEFAULT_ARTICLE_ID) && propsHistory.length === 0 ? [getNewHistoryItem(propsArticleId.id, propsArticleId.type)] : propsHistory,
212
252
  view: VIEW.DEFAULT_CONTENT
213
253
  });
214
254
  const isOverlayVisible = useMemo(() => {
@@ -221,8 +261,6 @@ export const NavigationContextProvider = ({
221
261
  /**
222
262
  * - If default content isn't defined and the history only has one article,
223
263
  * we should not display the back button
224
- * - If the prop.article.setArticleId is not defined, we should also hide the back
225
- * button because we are not able to navigate though the history without it
226
264
  */
227
265
  if (currentHistory.length === 1 && !isDefaultContentDefined || currentView === VIEW.WHATS_NEW && !isDefaultContentDefined) {
228
266
  return false;
@@ -339,6 +377,12 @@ export const NavigationContextProvider = ({
339
377
  onCloseButtonClick(event, analyticsEvent);
340
378
  }
341
379
  }, [onCloseButtonClick]);
380
+ const onOpenArticle = useCallback(newArticleId => {
381
+ dispatchNavigationAction({
382
+ type: 'addNewHistoryItem',
383
+ payload: newArticleId
384
+ });
385
+ }, []);
342
386
  useEffect(() => {
343
387
  if (isSearchResultVisible) {
344
388
  dispatchNavigationAction({
@@ -348,43 +392,59 @@ export const NavigationContextProvider = ({
348
392
  }
349
393
  }, [isSearchResultVisible]);
350
394
  useEffect(() => {
351
- const simpleHistory = getSimpleHistory(currentHistory);
352
- historySetter && historySetter(simpleHistory);
353
- }, [historySetter, currentHistory]);
354
- useEffect(() => {
395
+ const lastHistoryItem = currentHistory.length > 0 ? getCurrentArticle(currentHistory) : getNewHistoryItem(DEFAULT_ARTICLE_ID.id, DEFAULT_ARTICLE_ID.type);
355
396
  /**
356
397
  * If the propsArticleId.id (host articleId) is different from currentArticleId.id (internal articleId)
357
- * it means the host updated propsArticleId and we need to use this new value to load a new article.
358
398
  * */
359
- if ((propsArticleId === null || propsArticleId === void 0 ? void 0 : propsArticleId.id) !== currentArticleId.id || (propsArticleId === null || propsArticleId === void 0 ? void 0 : propsArticleId.type) !== currentArticleId.type) {
360
- dispatchNavigationAction({
361
- type: 'newArticle',
362
- payload: propsArticleId
363
- });
364
- } else {
399
+
400
+ if (!isEqual(propsArticleId, currentArticleId)) {
365
401
  /**
366
- * If the propsArticleId.id (host articleId) is equal to currentArticleId.id (internal articleId)
367
- * and the id from the last history item is different from currentArticleId.id, it means the history
368
- * changed and we need to update the host articleId (propsArticleId) using 'articleIdSetter' and the local
369
- * history using the dispatchNavigationAction reducer
370
- * */
371
- const lastHistoryItem = currentHistory.length > 0 ? getCurrentArticle(currentHistory) : getNewHistoryItem('', ARTICLE_TYPE.HELP_ARTICLE);
372
-
373
- if (articleIdSetter && lastHistoryItem && (currentArticleId.id !== lastHistoryItem.id || currentArticleId.type !== lastHistoryItem.type)) {
402
+ * If propsArticleId and lastHistoryItem are the same, we just need to update the articleId
403
+ * because is out of sync
404
+ */
405
+ if (propsArticleId.id === lastHistoryItem.id && propsArticleId.type === lastHistoryItem.type) {
374
406
  dispatchNavigationAction({
375
407
  type: 'updateArticleId',
376
- payload: {
377
- id: lastHistoryItem.id,
378
- type: lastHistoryItem.type
379
- }
408
+ payload: propsArticleId
380
409
  });
381
- articleIdSetter({
382
- id: lastHistoryItem.id,
383
- type: lastHistoryItem.type
410
+ } else {
411
+ /**
412
+ * Otherwise we need to add a new article
413
+ */
414
+ dispatchNavigationAction({
415
+ type: 'newArticle',
416
+ payload: propsArticleId
384
417
  });
385
418
  }
419
+ } else {
420
+ // console.log('same articleId');
421
+ if (setNavigationData) {
422
+ const simpleHistory = getSimpleHistory(currentHistory);
423
+
424
+ if (currentArticleId.id !== lastHistoryItem.id || currentArticleId.type !== lastHistoryItem.type) {
425
+ /**
426
+ * If the propsArticleId.id (host articleId) is equal to currentArticleId.id (internal articleId)
427
+ * and the id from the last history item is different from currentArticleId.id, it means the history
428
+ * changed
429
+ * */
430
+ if (setNavigationData) {
431
+ setNavigationData({
432
+ articleId: {
433
+ id: lastHistoryItem.id,
434
+ type: lastHistoryItem.type
435
+ },
436
+ history: simpleHistory
437
+ });
438
+ }
439
+ } else if (!isEqual(getHistoryData(propsHistory), getHistoryData(currentHistory))) {
440
+ setNavigationData({
441
+ articleId: propsArticleId,
442
+ history: simpleHistory
443
+ });
444
+ }
445
+ }
386
446
  }
387
- }, [currentArticleId, propsArticleId, currentHistory, articleIdSetter]);
447
+ }, [currentArticleId, propsArticleId, currentHistory, setNavigationData, propsHistory]);
388
448
  useEffect(() => {
389
449
  const requestNewArticle = async historyItem => {
390
450
  const historyItemUpdate = await fetchArticleData(historyItem);
@@ -408,7 +468,7 @@ export const NavigationContextProvider = ({
408
468
  value: {
409
469
  view: currentView,
410
470
  articleId: currentArticleId,
411
- setArticleId: articleIdSetter,
471
+ openArticle: onOpenArticle,
412
472
  history: currentHistory,
413
473
  getCurrentArticle: () => getCurrentArticle(currentHistory),
414
474
  getCurrentArticleItemData: () => getCurrentArticleItemSlim(currentHistory),
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/help",
3
- "version": "6.0.7",
3
+ "version": "7.0.2",
4
4
  "sideEffects": false
5
5
  }
@@ -14,7 +14,7 @@ export var HelpArticle = function HelpArticle(_ref) {
14
14
  isLoading = _ref.isLoading;
15
15
 
16
16
  var _useNavigationContext = useNavigationContext(),
17
- setArticleId = _useNavigationContext.setArticleId,
17
+ openArticle = _useNavigationContext.openArticle,
18
18
  getCurrentArticleItemData = _useNavigationContext.getCurrentArticleItemData;
19
19
 
20
20
  var _useHelpArticleContex = useHelpArticleContext(),
@@ -56,13 +56,11 @@ export var HelpArticle = function HelpArticle(_ref) {
56
56
  onRelatedArticlesListItemClick(event, analyticsEvent, articleData);
57
57
  }
58
58
 
59
- if (setArticleId) {
60
- setArticleId({
61
- id: articleData.id,
62
- type: ARTICLE_TYPE.HELP_ARTICLE
63
- });
64
- }
65
- }, [setArticleId, onRelatedArticlesListItemClick]);
59
+ openArticle({
60
+ id: articleData.id,
61
+ type: ARTICLE_TYPE.HELP_ARTICLE
62
+ });
63
+ }, [openArticle, onRelatedArticlesListItemClick]);
66
64
  var handleOnRelatedArticlesShowMoreClick = useCallback(function (event, analyticsEvent, isCollapsed) {
67
65
  analyticsEvent.payload.attributes = {
68
66
  componentName: 'Article',
@@ -1,9 +1,9 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
 
4
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
4
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
5
5
 
6
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
6
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
7
7
 
8
8
  import React, { useState, useLayoutEffect, useRef, useEffect, useCallback } from 'react';
9
9
  import { Transition } from 'react-transition-group';
@@ -5,6 +5,7 @@ import _createClass from "@babel/runtime/helpers/createClass";
5
5
  import _inherits from "@babel/runtime/helpers/inherits";
6
6
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
7
7
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
8
+ var _excluded = ["children", "footer"];
8
9
 
9
10
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
10
11
 
@@ -39,7 +40,7 @@ export var Help = /*#__PURE__*/function (_React$PureComponent) {
39
40
  var _this$props = this.props,
40
41
  children = _this$props.children,
41
42
  footer = _this$props.footer,
42
- rest = _objectWithoutProperties(_this$props, ["children", "footer"]);
43
+ rest = _objectWithoutProperties(_this$props, _excluded);
43
44
 
44
45
  return /*#__PURE__*/React.createElement(HeaderContextProvider, rest.header, /*#__PURE__*/React.createElement(HomeContextProvider, _extends({}, rest.home, {
45
46
  homeContent: children
@@ -1,8 +1,8 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
 
3
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
3
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
4
 
5
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
5
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
6
 
7
7
  import React, { useCallback } from 'react';
8
8
  import { Transition } from 'react-transition-group';
@@ -50,19 +50,16 @@ export var SearchResults = function SearchResults() {
50
50
  onSearchExternalUrlClick = _useSearchContext.onSearchExternalUrlClick;
51
51
 
52
52
  var _useNavigationContext = useNavigationContext(),
53
- setArticleId = _useNavigationContext.setArticleId,
53
+ openArticle = _useNavigationContext.openArticle,
54
54
  view = _useNavigationContext.view;
55
55
 
56
56
  var handleOnSearchResultItemClick = useCallback(function (event, analyticsEvent, articleData) {
57
- if (setArticleId) {
58
- setArticleId({
59
- id: articleData.id,
60
- type: ARTICLE_TYPE.HELP_ARTICLE
61
- });
62
- }
63
-
57
+ openArticle({
58
+ id: articleData.id,
59
+ type: ARTICLE_TYPE.HELP_ARTICLE
60
+ });
64
61
  onSearchResultItemClick(event, analyticsEvent, articleData);
65
- }, [onSearchResultItemClick, setArticleId]);
62
+ }, [onSearchResultItemClick, openArticle]);
66
63
  return /*#__PURE__*/React.createElement(Transition, {
67
64
  in: view === VIEW.SEARCH && isSearchResultVisible,
68
65
  timeout: FADEIN_OVERLAY_TRANSITION_DURATION_MS
@@ -23,20 +23,18 @@ export var WhatsNewButton = function WhatsNewButton(_ref) {
23
23
  whatsNewGetNotificationProvider = _useWhatsNewArticleCo.whatsNewGetNotificationProvider;
24
24
 
25
25
  var _useNavigationContext = useNavigationContext(),
26
- setArticleId = _useNavigationContext.setArticleId;
26
+ openArticle = _useNavigationContext.openArticle;
27
27
 
28
28
  var handleOnButtonClick = useCallback(function (id, analytics, event) {
29
29
  if (onWhatsNewButtonClick) {
30
30
  onWhatsNewButtonClick(event, analytics);
31
31
  }
32
32
 
33
- if (setArticleId) {
34
- setArticleId({
35
- id: '',
36
- type: ARTICLE_TYPE.WHATS_NEW
37
- });
38
- }
39
- }, [onWhatsNewButtonClick, setArticleId]);
33
+ openArticle({
34
+ id: '',
35
+ type: ARTICLE_TYPE.WHATS_NEW
36
+ });
37
+ }, [onWhatsNewButtonClick, openArticle]);
40
38
  return /*#__PURE__*/React.createElement(HelpContentButton, {
41
39
  id: "whats-new",
42
40
  key: "whats-new",
@@ -27,7 +27,7 @@ var WhatsNewResultsList = function WhatsNewResultsList(_ref) {
27
27
  var featureRolloutDateString = whatsNewArticle === null || whatsNewArticle === void 0 ? void 0 : whatsNewArticle.featureRolloutDate;
28
28
 
29
29
  if (featureRolloutDateString) {
30
- var featureRolloutDateArray = featureRolloutDateString.replace('-', '/');
30
+ var featureRolloutDateArray = featureRolloutDateString.replace('/-/g', '/');
31
31
  var featureRolloutDate = toDate(new Date(featureRolloutDateArray));
32
32
 
33
33
  if (whatsNewArticlesGroupedByDateTemp[featureRolloutDateString]) {
@@ -31,7 +31,7 @@ var WhatsNewResultsList = function WhatsNewResultsList(_ref) {
31
31
  onShowMoreButtonClick = _ref.onShowMoreButtonClick;
32
32
 
33
33
  var _useNavigationContext = useNavigationContext(),
34
- setArticleId = _useNavigationContext.setArticleId;
34
+ openArticle = _useNavigationContext.openArticle;
35
35
 
36
36
  var handleShowMoreButtonClick = function handleShowMoreButtonClick(event, analyticsEvent) {
37
37
  if (onShowMoreButtonClick) {
@@ -40,17 +40,15 @@ var WhatsNewResultsList = function WhatsNewResultsList(_ref) {
40
40
  };
41
41
 
42
42
  var handleOnWhatsNewResultItemClick = useCallback(function (event, analyticsEvent, articleData) {
43
- if (setArticleId) {
44
- setArticleId({
45
- id: articleData.id,
46
- type: ARTICLE_TYPE.WHATS_NEW
47
- });
48
- }
43
+ openArticle({
44
+ id: articleData.id,
45
+ type: ARTICLE_TYPE.WHATS_NEW
46
+ });
49
47
 
50
48
  if (onWhatsNewResultItemClick) {
51
49
  onWhatsNewResultItemClick(event, analyticsEvent, articleData);
52
50
  }
53
- }, [onWhatsNewResultItemClick, setArticleId]);
51
+ }, [onWhatsNewResultItemClick, openArticle]);
54
52
  return whatsNewArticles && whatsNewArticles.length > 0 ? /*#__PURE__*/React.createElement(WhatsNewResultsListContainer, null, /*#__PURE__*/React.createElement(ThemeProvider, {
55
53
  theme: _defineProperty({}, itemThemeNamespace, ITEM_THEME)
56
54
  }, /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ArticlesList, {
@@ -1,12 +1,13 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
 
4
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
4
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
5
5
 
6
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
6
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
7
7
 
8
- import React, { useCallback, useState } from 'react';
8
+ import React, { useCallback, useState, useRef } from 'react';
9
9
  import { Transition } from 'react-transition-group';
10
+ import isEqual from 'lodash/isEqual';
10
11
  import Select from '@atlaskit/select';
11
12
  import { injectIntl } from 'react-intl-next';
12
13
  import { VIEW } from '../../constants';
@@ -56,12 +57,18 @@ export var WhatsNewResults = function WhatsNewResults(_ref) {
56
57
  searchWhatsNewArticlesState = _useWhatsNewArticleCo.searchWhatsNewArticlesState,
57
58
  onWhatsNewResultItemClick = _useWhatsNewArticleCo.onWhatsNewResultItemClick;
58
59
 
60
+ var containerRef = useRef(null);
61
+ var containerScrollPosition = useRef(0);
59
62
  var SELECT_DEFAULT_VALUE = {
60
63
  value: '',
61
64
  label: formatMessage(messages.help_whats_new_filter_select_option_all)
62
65
  };
66
+ var SELECT_EMPTY_VALUE = {
67
+ value: undefined,
68
+ label: ''
69
+ };
63
70
 
64
- var _useState = useState(SELECT_DEFAULT_VALUE),
71
+ var _useState = useState(SELECT_EMPTY_VALUE),
65
72
  _useState2 = _slicedToArray(_useState, 2),
66
73
  selectedOption = _useState2[0],
67
74
  setSelectedOption = _useState2[1];
@@ -78,8 +85,25 @@ export var WhatsNewResults = function WhatsNewResults(_ref) {
78
85
  }, [onSearchWhatsNewArticles, searchWhatsNewArticlesResult, selectedOption]);
79
86
 
80
87
  var handleOnEnter = function handleOnEnter() {
81
- setSelectedOption(SELECT_DEFAULT_VALUE);
82
- onSearchWhatsNewArticles && onSearchWhatsNewArticles();
88
+ setTimeout(function () {
89
+ if (containerRef.current) {
90
+ containerRef.current.scrollTop = containerScrollPosition.current;
91
+ }
92
+ }, 0);
93
+
94
+ if (isEqual(selectedOption, SELECT_EMPTY_VALUE)) {
95
+ setSelectedOption(SELECT_DEFAULT_VALUE);
96
+ onSearchWhatsNewArticles && onSearchWhatsNewArticles();
97
+ }
98
+ };
99
+
100
+ var handleOnExit = function handleOnExit() {
101
+ if (helpContextView === VIEW.DEFAULT_CONTENT) {
102
+ setSelectedOption(SELECT_EMPTY_VALUE);
103
+ containerScrollPosition.current = 0;
104
+ } else {
105
+ containerScrollPosition.current = containerRef.current ? containerRef.current.scrollTop : 0;
106
+ }
83
107
  };
84
108
 
85
109
  var handleOnClearFilter = function handleOnClearFilter() {
@@ -95,9 +119,11 @@ export var WhatsNewResults = function WhatsNewResults(_ref) {
95
119
  return /*#__PURE__*/React.createElement(Transition, {
96
120
  in: helpContextView === VIEW.WHATS_NEW,
97
121
  timeout: FADEIN_OVERLAY_TRANSITION_DURATION_MS,
98
- onEnter: handleOnEnter
122
+ onEnter: handleOnEnter,
123
+ onExit: handleOnExit
99
124
  }, function (state) {
100
125
  return /*#__PURE__*/React.createElement(WhatsNewResultsContainer, {
126
+ ref: containerRef,
101
127
  style: _objectSpread(_objectSpread({}, defaultStyle), transitionStyles[state])
102
128
  }, /*#__PURE__*/React.createElement(React.Fragment, null, searchWhatsNewArticlesState === REQUEST_STATE.loading && searchWhatsNewArticlesResult === null && state !== 'exited' && /*#__PURE__*/React.createElement(WhatsNewResultsLoading, null), (searchWhatsNewArticlesState === REQUEST_STATE.done || searchWhatsNewArticlesState === REQUEST_STATE.loading) && searchWhatsNewArticlesResult !== null && state !== 'exited' && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SelectContainer, null, /*#__PURE__*/React.createElement(Select, {
103
129
  defaultValue: selectedOption,