@atlaskit/emoji 73.6.1 → 73.6.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,14 @@
1
1
  # @atlaskit/emoji
2
2
 
3
+ ## 73.6.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`157b7c1f3d2e0`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/157b7c1f3d2e0) -
8
+ Restore focus to the emoji's delete button after cancelling deletion in the emoji picker, behind
9
+ the `platform_ally_emoji_fixes_various` feature gate.
10
+ - Updated dependencies
11
+
3
12
  ## 73.6.1
4
13
 
5
14
  ### Patch Changes
@@ -7,9 +7,12 @@
7
7
  ._19pkutpp{margin-top:var(--ds-space-150,9pt)}
8
8
  ._1bah1h6o{justify-content:center}
9
9
  ._1bahesu3{justify-content:flex-end}
10
+ ._1bsb1osq{width:100%}
10
11
  ._1e0c1txw{display:flex}
12
+ ._1i4qfg65{overflow-wrap:anywhere}
11
13
  ._1o9zkb7n{flex-shrink:1}
12
14
  ._1tke1sa4{min-height:390px}
15
+ ._1ul9idpf{min-width:0}
13
16
  ._2lx21bp4{flex-direction:column}
14
17
  ._4cvr1h6o{align-items:center}
15
18
  ._4cvr1y6m{align-items:flex-start}
@@ -22,6 +22,7 @@ var _reactFocusLock = _interopRequireDefault(require("react-focus-lock"));
22
22
  var _reactIntl = require("react-intl");
23
23
  var _button = _interopRequireDefault(require("@atlaskit/button/default/button"));
24
24
  var _heading = _interopRequireDefault(require("@atlaskit/heading/heading"));
25
+ var _fg = require("@atlaskit/platform-feature-flags/fg");
25
26
  var _box = require("@atlaskit/primitives/compiled/box");
26
27
  var _text = require("@atlaskit/primitives/compiled/text");
27
28
  var _visuallyHidden = _interopRequireDefault(require("@atlaskit/visually-hidden/visually-hidden"));
@@ -34,6 +35,7 @@ function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0,
34
35
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } // eslint-disable-next-line @atlaskit/design-system/no-third-party-focus-traps -- existing usage from before this rule was added
35
36
  var deletePreviewNew = null;
36
37
  var deleteTextSection = null;
38
+ var deleteDescriptionText = null;
37
39
  var emojiPreviewLargeBox = null;
38
40
  var deleteButtonGroup = null;
39
41
  var emojiDeletePreviewTestId = exports.emojiDeletePreviewTestId = 'emoji-delete-preview';
@@ -99,7 +101,10 @@ var EmojiDeletePreview = /*#__PURE__*/function (_Component) {
99
101
  error = _this$state.error;
100
102
  var formatMessage = intl.formatMessage;
101
103
  return /*#__PURE__*/React.createElement(_reactFocusLock.default, {
102
- noFocusGuards: true
104
+ noFocusGuards: true,
105
+ focusOptions: (0, _fg.fg)('platform_ally_emoji_fixes_various') ? {
106
+ preventScroll: true
107
+ } : undefined
103
108
  }, /*#__PURE__*/React.createElement("div", {
104
109
  "data-testid": emojiDeletePreviewTestId,
105
110
  className: (0, _runtime.ax)(["_zulputpp _1e0c1txw _2lx21bp4 _1tke1sa4 _ca0qutpp _u5f3pxbi _n3tdutpp _19bvpxbi _vchhusvi"])
@@ -109,7 +114,17 @@ var EmojiDeletePreview = /*#__PURE__*/function (_Component) {
109
114
  paddingBlockEnd: "space.100"
110
115
  }, /*#__PURE__*/React.createElement(_heading.default, {
111
116
  size: "small"
112
- }, /*#__PURE__*/React.createElement(_reactIntl.FormattedMessage, _i18n.messages.deleteEmojiTitle))), /*#__PURE__*/React.createElement(_text.Text, {
117
+ }, /*#__PURE__*/React.createElement(_reactIntl.FormattedMessage, _i18n.messages.deleteEmojiTitle))), (0, _fg.fg)('platform_ally_emoji_fixes_various') ? /*#__PURE__*/React.createElement("div", {
118
+ className: (0, _runtime.ax)(["_1bsb1osq _1ul9idpf _1i4qfg65"])
119
+ }, /*#__PURE__*/React.createElement(_text.Text, {
120
+ color: "color.text.subtle",
121
+ size: "small",
122
+ maxLines: 2
123
+ }, /*#__PURE__*/React.createElement(_reactIntl.FormattedMessage, (0, _extends2.default)({}, _i18n.messages.deleteEmojiDescription, {
124
+ values: {
125
+ emojiShortName: emoji.shortName
126
+ }
127
+ })))) : /*#__PURE__*/React.createElement(_text.Text, {
113
128
  color: "color.text.subtle",
114
129
  size: "small"
115
130
  }, /*#__PURE__*/React.createElement(_reactIntl.FormattedMessage, (0, _extends2.default)({}, _i18n.messages.deleteEmojiDescription, {
@@ -123,6 +123,10 @@ var EmojiPickerVirtualListInternal = exports.EmojiPickerVirtualListInternal = /*
123
123
  _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
124
124
  lastYourUploadsRow = _useState6[0],
125
125
  setLastYourUploadsRow = _useState6[1];
126
+ // id of emoji that should regain focus after the delete preview is cancelled
127
+ var emojiToRestoreFocusRef = (0, _react.useRef)();
128
+ // whether delete has been confirmed, so closing the delete preview is not a cancel
129
+ var isDeletingEmojiRef = (0, _react.useRef)(false);
126
130
  var _useState7 = (0, _react.useState)(null),
127
131
  _useState8 = (0, _slicedToArray2.default)(_useState7, 2),
128
132
  activeAtlassianSubcategory = _useState8[0],
@@ -401,13 +405,32 @@ var EmojiPickerVirtualListInternal = exports.EmojiPickerVirtualListInternal = /*
401
405
  var handleOnCloseDelete = function handleOnCloseDelete() {
402
406
  var list = listRef.current;
403
407
  list === null || list === void 0 || list.updateFocusIndex(lastYourUploadsRow);
408
+ if ((0, _fg.fg)('platform_ally_emoji_fixes_various') && emojiToDelete !== null && emojiToDelete !== void 0 && emojiToDelete.id && !isDeletingEmojiRef.current) {
409
+ // delete was cancelled, restore focus to that emoji once the delete preview is closed
410
+ emojiToRestoreFocusRef.current = emojiToDelete.id;
411
+ }
412
+ isDeletingEmojiRef.current = false;
404
413
  onCloseDelete();
405
414
  };
415
+ var handleOnDeleteEmoji = function handleOnDeleteEmoji(emoji) {
416
+ isDeletingEmojiRef.current = true;
417
+ return onDeleteEmoji(emoji).then(function (success) {
418
+ if (!success) {
419
+ // deletion failed and the delete preview stays open, so a later cancel should still restore focus
420
+ isDeletingEmojiRef.current = false;
421
+ }
422
+ return success;
423
+ });
424
+ };
406
425
  var findEmojiRowAndColumnById = function findEmojiRowAndColumnById(emojiId) {
426
+ var deletableOnly = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
407
427
  var columnIndex = -1;
408
428
  // for most of cases, it'd be in first emoji row, so should be quite fast to find in real world
409
429
  var rowIndex = virtualItems.findIndex(function (rowItem) {
410
430
  if (rowItem instanceof _EmojisRowItem.EmojisRowItem) {
431
+ if (deletableOnly && !rowItem.props.showDelete) {
432
+ return false;
433
+ }
411
434
  // find uploaded emoji in each emoji row
412
435
  columnIndex = rowItem.props.emojis.findIndex(function (emoji) {
413
436
  return emoji.id === emojiId;
@@ -482,6 +505,22 @@ var EmojiPickerVirtualListInternal = exports.EmojiPickerVirtualListInternal = /*
482
505
  (0, _react.useEffect)(function () {
483
506
  buildVirtualItems();
484
507
  }, [allEmojiGroups, buildVirtualItems]);
508
+ (0, _react.useEffect)(function () {
509
+ var emojiId = emojiToRestoreFocusRef.current;
510
+ if (emojiToDelete || !emojiId || !(0, _fg.fg)('platform_ally_emoji_fixes_various')) {
511
+ return;
512
+ }
513
+ emojiToRestoreFocusRef.current = undefined;
514
+ // delete is only triggered from deletable emojis (i.e. "Your uploads"), so prefer those rows
515
+ var _findEmojiRowAndColum2 = findEmojiRowAndColumnById(emojiId, true),
516
+ rowIndex = _findEmojiRowAndColum2.rowIndex,
517
+ columnIndex = _findEmojiRowAndColum2.columnIndex;
518
+ if (rowIndex !== -1) {
519
+ var _listRef$current5;
520
+ (_listRef$current5 = listRef.current) === null || _listRef$current5 === void 0 || _listRef$current5.focusEmojiPreservingScroll(rowIndex, columnIndex);
521
+ }
522
+ // eslint-disable-next-line react-hooks/exhaustive-deps
523
+ }, [emojiToDelete]);
485
524
  (0, _react.useEffect)(function () {
486
525
  if (categoriesChanged) {
487
526
  onRowsRendered({
@@ -518,7 +557,7 @@ var EmojiPickerVirtualListInternal = exports.EmojiPickerVirtualListInternal = /*
518
557
  onUploadCancelled: onUploadCancelled,
519
558
  onUploadEmoji: onUploadEmoji,
520
559
  onCloseDelete: handleOnCloseDelete,
521
- onDeleteEmoji: onDeleteEmoji,
560
+ onDeleteEmoji: (0, _fg.fg)('platform_ally_emoji_fixes_various') ? handleOnDeleteEmoji : onDeleteEmoji,
522
561
  onFileChooserClicked: onFileChooserClicked,
523
562
  onOpenUpload: onOpenUpload,
524
563
  onProductivityColorSelected: onProductivityColorSelected,
@@ -251,11 +251,42 @@ var VirtualList = exports.VirtualList = /*#__PURE__*/_react.default.forwardRef(f
251
251
  scrollToEmojiAndFocus: function scrollToEmojiAndFocus(rowIndex, columnIndex) {
252
252
  focusEmoji(rowIndex, columnIndex, _constants.KeyboardNavigationDirection.Left, true);
253
253
  },
254
+ focusEmojiPreservingScroll: function focusEmojiPreservingScroll(rowIndex, columnIndex) {
255
+ var getEmojiElement = function getEmojiElement() {
256
+ var _virtualistItemsRef$c2;
257
+ return (_virtualistItemsRef$c2 = virtualistItemsRef.current) === null || _virtualistItemsRef$c2 === void 0 ? void 0 : _virtualistItemsRef$c2.querySelector("[data-focus-index=\"".concat(rowIndex, "-").concat(columnIndex, "\"]"));
258
+ };
259
+ var focusEmojiElement = function focusEmojiElement(emojiElement) {
260
+ setEmojisFocus({
261
+ rowIndex: rowIndex,
262
+ columnIndex: columnIndex
263
+ });
264
+ emojiElement.focus({
265
+ preventScroll: true
266
+ });
267
+ };
268
+
269
+ // keep the current scroll position if the emoji is still visible in the list
270
+ var renderedEmojiElement = getEmojiElement();
271
+ if (renderedEmojiElement && isElementVisible(renderedEmojiElement)) {
272
+ focusEmojiElement(renderedEmojiElement);
273
+ return;
274
+ }
275
+
276
+ // otherwise scroll to target rowIndex first to ensure the row is rendered in list.
277
+ rowVirtualizer.scrollToIndex(rowIndex);
278
+ setTimeout(function () {
279
+ var emojiElement = getEmojiElement();
280
+ if (emojiElement) {
281
+ focusEmojiElement(emojiElement);
282
+ }
283
+ }, 100); // 100ms is virtual list scrolling time
284
+ },
254
285
  updateFocusIndex: function updateFocusIndex(rowIndex) {
255
- var _virtualistItemsRef$c2;
286
+ var _virtualistItemsRef$c3;
256
287
  var columnIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
257
288
  // row could be removed from virtual list after scrolling, we'll update emoji cell tabIndex after losing focus
258
- if (!((_virtualistItemsRef$c2 = virtualistItemsRef.current) !== null && _virtualistItemsRef$c2 !== void 0 && _virtualistItemsRef$c2.contains(document.activeElement))) {
289
+ if (!((_virtualistItemsRef$c3 = virtualistItemsRef.current) !== null && _virtualistItemsRef$c3 !== void 0 && _virtualistItemsRef$c3.contains(document.activeElement))) {
259
290
  setEmojisFocus({
260
291
  rowIndex: rowIndex,
261
292
  columnIndex: columnIndex
@@ -7,9 +7,12 @@
7
7
  ._19pkutpp{margin-top:var(--ds-space-150,9pt)}
8
8
  ._1bah1h6o{justify-content:center}
9
9
  ._1bahesu3{justify-content:flex-end}
10
+ ._1bsb1osq{width:100%}
10
11
  ._1e0c1txw{display:flex}
12
+ ._1i4qfg65{overflow-wrap:anywhere}
11
13
  ._1o9zkb7n{flex-shrink:1}
12
14
  ._1tke1sa4{min-height:390px}
15
+ ._1ul9idpf{min-width:0}
13
16
  ._2lx21bp4{flex-direction:column}
14
17
  ._4cvr1h6o{align-items:center}
15
18
  ._4cvr1y6m{align-items:flex-start}
@@ -10,6 +10,7 @@ import FocusLock from 'react-focus-lock';
10
10
  import { FormattedMessage, injectIntl } from 'react-intl';
11
11
  import AkButton from '@atlaskit/button/default/button';
12
12
  import Heading from '@atlaskit/heading/heading';
13
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
13
14
  import { Box } from '@atlaskit/primitives/compiled/box';
14
15
  import { Text } from '@atlaskit/primitives/compiled/text';
15
16
  import VisuallyHidden from '@atlaskit/visually-hidden/visually-hidden';
@@ -19,6 +20,7 @@ import EmojiErrorMessage, { emojiErrorScreenreaderTestId } from './EmojiErrorMes
19
20
  import RetryableButton from './RetryableButton';
20
21
  const deletePreviewNew = null;
21
22
  const deleteTextSection = null;
23
+ const deleteDescriptionText = null;
22
24
  const emojiPreviewLargeBox = null;
23
25
  const deleteButtonGroup = null;
24
26
  export const emojiDeletePreviewTestId = 'emoji-delete-preview';
@@ -81,7 +83,10 @@ class EmojiDeletePreview extends Component {
81
83
  formatMessage
82
84
  } = intl;
83
85
  return /*#__PURE__*/React.createElement(FocusLock, {
84
- noFocusGuards: true
86
+ noFocusGuards: true,
87
+ focusOptions: fg('platform_ally_emoji_fixes_various') ? {
88
+ preventScroll: true
89
+ } : undefined
85
90
  }, /*#__PURE__*/React.createElement("div", {
86
91
  "data-testid": emojiDeletePreviewTestId,
87
92
  className: ax(["_zulputpp _1e0c1txw _2lx21bp4 _1tke1sa4 _ca0qutpp _u5f3pxbi _n3tdutpp _19bvpxbi _vchhusvi"])
@@ -91,7 +96,17 @@ class EmojiDeletePreview extends Component {
91
96
  paddingBlockEnd: "space.100"
92
97
  }, /*#__PURE__*/React.createElement(Heading, {
93
98
  size: "small"
94
- }, /*#__PURE__*/React.createElement(FormattedMessage, messages.deleteEmojiTitle))), /*#__PURE__*/React.createElement(Text, {
99
+ }, /*#__PURE__*/React.createElement(FormattedMessage, messages.deleteEmojiTitle))), fg('platform_ally_emoji_fixes_various') ? /*#__PURE__*/React.createElement("div", {
100
+ className: ax(["_1bsb1osq _1ul9idpf _1i4qfg65"])
101
+ }, /*#__PURE__*/React.createElement(Text, {
102
+ color: "color.text.subtle",
103
+ size: "small",
104
+ maxLines: 2
105
+ }, /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages.deleteEmojiDescription, {
106
+ values: {
107
+ emojiShortName: emoji.shortName
108
+ }
109
+ })))) : /*#__PURE__*/React.createElement(Text, {
95
110
  color: "color.text.subtle",
96
111
  size: "small"
97
112
  }, /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages.deleteEmojiDescription, {
@@ -99,6 +99,10 @@ export const EmojiPickerVirtualListInternal = /*#__PURE__*/React.forwardRef((pro
99
99
  const [allEmojiGroups, setAllEmojiGroups] = useState([]);
100
100
  const [virtualItems, setVirtualItems] = useState([]);
101
101
  const [lastYourUploadsRow, setLastYourUploadsRow] = useState(0);
102
+ // id of emoji that should regain focus after the delete preview is cancelled
103
+ const emojiToRestoreFocusRef = useRef();
104
+ // whether delete has been confirmed, so closing the delete preview is not a cancel
105
+ const isDeletingEmojiRef = useRef(false);
102
106
  const [activeAtlassianSubcategory, setActiveAtlassianSubcategory] = useState(null);
103
107
  const categoryTracker = useMemo(() => new CategoryTracker(), []);
104
108
  const [categoriesChanged, setCategoriesChanged] = useState(false);
@@ -359,13 +363,31 @@ export const EmojiPickerVirtualListInternal = /*#__PURE__*/React.forwardRef((pro
359
363
  const handleOnCloseDelete = () => {
360
364
  const list = listRef.current;
361
365
  list === null || list === void 0 ? void 0 : list.updateFocusIndex(lastYourUploadsRow);
366
+ if (fg('platform_ally_emoji_fixes_various') && emojiToDelete !== null && emojiToDelete !== void 0 && emojiToDelete.id && !isDeletingEmojiRef.current) {
367
+ // delete was cancelled, restore focus to that emoji once the delete preview is closed
368
+ emojiToRestoreFocusRef.current = emojiToDelete.id;
369
+ }
370
+ isDeletingEmojiRef.current = false;
362
371
  onCloseDelete();
363
372
  };
364
- const findEmojiRowAndColumnById = emojiId => {
373
+ const handleOnDeleteEmoji = emoji => {
374
+ isDeletingEmojiRef.current = true;
375
+ return onDeleteEmoji(emoji).then(success => {
376
+ if (!success) {
377
+ // deletion failed and the delete preview stays open, so a later cancel should still restore focus
378
+ isDeletingEmojiRef.current = false;
379
+ }
380
+ return success;
381
+ });
382
+ };
383
+ const findEmojiRowAndColumnById = (emojiId, deletableOnly = false) => {
365
384
  let columnIndex = -1;
366
385
  // for most of cases, it'd be in first emoji row, so should be quite fast to find in real world
367
386
  let rowIndex = virtualItems.findIndex(rowItem => {
368
387
  if (rowItem instanceof EmojisRowItem) {
388
+ if (deletableOnly && !rowItem.props.showDelete) {
389
+ return false;
390
+ }
369
391
  // find uploaded emoji in each emoji row
370
392
  columnIndex = rowItem.props.emojis.findIndex(emoji => emoji.id === emojiId);
371
393
  return columnIndex !== -1;
@@ -437,6 +459,23 @@ export const EmojiPickerVirtualListInternal = /*#__PURE__*/React.forwardRef((pro
437
459
  useEffect(() => {
438
460
  buildVirtualItems();
439
461
  }, [allEmojiGroups, buildVirtualItems]);
462
+ useEffect(() => {
463
+ const emojiId = emojiToRestoreFocusRef.current;
464
+ if (emojiToDelete || !emojiId || !fg('platform_ally_emoji_fixes_various')) {
465
+ return;
466
+ }
467
+ emojiToRestoreFocusRef.current = undefined;
468
+ // delete is only triggered from deletable emojis (i.e. "Your uploads"), so prefer those rows
469
+ const {
470
+ rowIndex,
471
+ columnIndex
472
+ } = findEmojiRowAndColumnById(emojiId, true);
473
+ if (rowIndex !== -1) {
474
+ var _listRef$current5;
475
+ (_listRef$current5 = listRef.current) === null || _listRef$current5 === void 0 ? void 0 : _listRef$current5.focusEmojiPreservingScroll(rowIndex, columnIndex);
476
+ }
477
+ // eslint-disable-next-line react-hooks/exhaustive-deps
478
+ }, [emojiToDelete]);
440
479
  useEffect(() => {
441
480
  if (categoriesChanged) {
442
481
  onRowsRendered({
@@ -473,7 +512,7 @@ export const EmojiPickerVirtualListInternal = /*#__PURE__*/React.forwardRef((pro
473
512
  onUploadCancelled: onUploadCancelled,
474
513
  onUploadEmoji: onUploadEmoji,
475
514
  onCloseDelete: handleOnCloseDelete,
476
- onDeleteEmoji: onDeleteEmoji,
515
+ onDeleteEmoji: fg('platform_ally_emoji_fixes_various') ? handleOnDeleteEmoji : onDeleteEmoji,
477
516
  onFileChooserClicked: onFileChooserClicked,
478
517
  onOpenUpload: onOpenUpload,
479
518
  onProductivityColorSelected: onProductivityColorSelected,
@@ -240,10 +240,41 @@ export const VirtualList = /*#__PURE__*/React.forwardRef((props, ref) => {
240
240
  scrollToEmojiAndFocus(rowIndex, columnIndex) {
241
241
  focusEmoji(rowIndex, columnIndex, KeyboardNavigationDirection.Left, true);
242
242
  },
243
+ focusEmojiPreservingScroll(rowIndex, columnIndex) {
244
+ const getEmojiElement = () => {
245
+ var _virtualistItemsRef$c2;
246
+ return (_virtualistItemsRef$c2 = virtualistItemsRef.current) === null || _virtualistItemsRef$c2 === void 0 ? void 0 : _virtualistItemsRef$c2.querySelector(`[data-focus-index="${rowIndex}-${columnIndex}"]`);
247
+ };
248
+ const focusEmojiElement = emojiElement => {
249
+ setEmojisFocus({
250
+ rowIndex,
251
+ columnIndex
252
+ });
253
+ emojiElement.focus({
254
+ preventScroll: true
255
+ });
256
+ };
257
+
258
+ // keep the current scroll position if the emoji is still visible in the list
259
+ const renderedEmojiElement = getEmojiElement();
260
+ if (renderedEmojiElement && isElementVisible(renderedEmojiElement)) {
261
+ focusEmojiElement(renderedEmojiElement);
262
+ return;
263
+ }
264
+
265
+ // otherwise scroll to target rowIndex first to ensure the row is rendered in list.
266
+ rowVirtualizer.scrollToIndex(rowIndex);
267
+ setTimeout(() => {
268
+ const emojiElement = getEmojiElement();
269
+ if (emojiElement) {
270
+ focusEmojiElement(emojiElement);
271
+ }
272
+ }, 100); // 100ms is virtual list scrolling time
273
+ },
243
274
  updateFocusIndex(rowIndex, columnIndex = 0) {
244
- var _virtualistItemsRef$c2;
275
+ var _virtualistItemsRef$c3;
245
276
  // row could be removed from virtual list after scrolling, we'll update emoji cell tabIndex after losing focus
246
- if (!((_virtualistItemsRef$c2 = virtualistItemsRef.current) !== null && _virtualistItemsRef$c2 !== void 0 && _virtualistItemsRef$c2.contains(document.activeElement))) {
277
+ if (!((_virtualistItemsRef$c3 = virtualistItemsRef.current) !== null && _virtualistItemsRef$c3 !== void 0 && _virtualistItemsRef$c3.contains(document.activeElement))) {
247
278
  setEmojisFocus({
248
279
  rowIndex,
249
280
  columnIndex
@@ -7,9 +7,12 @@
7
7
  ._19pkutpp{margin-top:var(--ds-space-150,9pt)}
8
8
  ._1bah1h6o{justify-content:center}
9
9
  ._1bahesu3{justify-content:flex-end}
10
+ ._1bsb1osq{width:100%}
10
11
  ._1e0c1txw{display:flex}
12
+ ._1i4qfg65{overflow-wrap:anywhere}
11
13
  ._1o9zkb7n{flex-shrink:1}
12
14
  ._1tke1sa4{min-height:390px}
15
+ ._1ul9idpf{min-width:0}
13
16
  ._2lx21bp4{flex-direction:column}
14
17
  ._4cvr1h6o{align-items:center}
15
18
  ._4cvr1y6m{align-items:flex-start}
@@ -17,6 +17,7 @@ import FocusLock from 'react-focus-lock';
17
17
  import { FormattedMessage, injectIntl } from 'react-intl';
18
18
  import AkButton from '@atlaskit/button/default/button';
19
19
  import Heading from '@atlaskit/heading/heading';
20
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
20
21
  import { Box } from '@atlaskit/primitives/compiled/box';
21
22
  import { Text } from '@atlaskit/primitives/compiled/text';
22
23
  import VisuallyHidden from '@atlaskit/visually-hidden/visually-hidden';
@@ -26,6 +27,7 @@ import EmojiErrorMessage, { emojiErrorScreenreaderTestId } from './EmojiErrorMes
26
27
  import RetryableButton from './RetryableButton';
27
28
  var deletePreviewNew = null;
28
29
  var deleteTextSection = null;
30
+ var deleteDescriptionText = null;
29
31
  var emojiPreviewLargeBox = null;
30
32
  var deleteButtonGroup = null;
31
33
  export var emojiDeletePreviewTestId = 'emoji-delete-preview';
@@ -91,7 +93,10 @@ var EmojiDeletePreview = /*#__PURE__*/function (_Component) {
91
93
  error = _this$state.error;
92
94
  var formatMessage = intl.formatMessage;
93
95
  return /*#__PURE__*/React.createElement(FocusLock, {
94
- noFocusGuards: true
96
+ noFocusGuards: true,
97
+ focusOptions: fg('platform_ally_emoji_fixes_various') ? {
98
+ preventScroll: true
99
+ } : undefined
95
100
  }, /*#__PURE__*/React.createElement("div", {
96
101
  "data-testid": emojiDeletePreviewTestId,
97
102
  className: ax(["_zulputpp _1e0c1txw _2lx21bp4 _1tke1sa4 _ca0qutpp _u5f3pxbi _n3tdutpp _19bvpxbi _vchhusvi"])
@@ -101,7 +106,17 @@ var EmojiDeletePreview = /*#__PURE__*/function (_Component) {
101
106
  paddingBlockEnd: "space.100"
102
107
  }, /*#__PURE__*/React.createElement(Heading, {
103
108
  size: "small"
104
- }, /*#__PURE__*/React.createElement(FormattedMessage, messages.deleteEmojiTitle))), /*#__PURE__*/React.createElement(Text, {
109
+ }, /*#__PURE__*/React.createElement(FormattedMessage, messages.deleteEmojiTitle))), fg('platform_ally_emoji_fixes_various') ? /*#__PURE__*/React.createElement("div", {
110
+ className: ax(["_1bsb1osq _1ul9idpf _1i4qfg65"])
111
+ }, /*#__PURE__*/React.createElement(Text, {
112
+ color: "color.text.subtle",
113
+ size: "small",
114
+ maxLines: 2
115
+ }, /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages.deleteEmojiDescription, {
116
+ values: {
117
+ emojiShortName: emoji.shortName
118
+ }
119
+ })))) : /*#__PURE__*/React.createElement(Text, {
105
120
  color: "color.text.subtle",
106
121
  size: "small"
107
122
  }, /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages.deleteEmojiDescription, {
@@ -115,6 +115,10 @@ export var EmojiPickerVirtualListInternal = /*#__PURE__*/React.forwardRef(functi
115
115
  _useState6 = _slicedToArray(_useState5, 2),
116
116
  lastYourUploadsRow = _useState6[0],
117
117
  setLastYourUploadsRow = _useState6[1];
118
+ // id of emoji that should regain focus after the delete preview is cancelled
119
+ var emojiToRestoreFocusRef = useRef();
120
+ // whether delete has been confirmed, so closing the delete preview is not a cancel
121
+ var isDeletingEmojiRef = useRef(false);
118
122
  var _useState7 = useState(null),
119
123
  _useState8 = _slicedToArray(_useState7, 2),
120
124
  activeAtlassianSubcategory = _useState8[0],
@@ -393,13 +397,32 @@ export var EmojiPickerVirtualListInternal = /*#__PURE__*/React.forwardRef(functi
393
397
  var handleOnCloseDelete = function handleOnCloseDelete() {
394
398
  var list = listRef.current;
395
399
  list === null || list === void 0 || list.updateFocusIndex(lastYourUploadsRow);
400
+ if (fg('platform_ally_emoji_fixes_various') && emojiToDelete !== null && emojiToDelete !== void 0 && emojiToDelete.id && !isDeletingEmojiRef.current) {
401
+ // delete was cancelled, restore focus to that emoji once the delete preview is closed
402
+ emojiToRestoreFocusRef.current = emojiToDelete.id;
403
+ }
404
+ isDeletingEmojiRef.current = false;
396
405
  onCloseDelete();
397
406
  };
407
+ var handleOnDeleteEmoji = function handleOnDeleteEmoji(emoji) {
408
+ isDeletingEmojiRef.current = true;
409
+ return onDeleteEmoji(emoji).then(function (success) {
410
+ if (!success) {
411
+ // deletion failed and the delete preview stays open, so a later cancel should still restore focus
412
+ isDeletingEmojiRef.current = false;
413
+ }
414
+ return success;
415
+ });
416
+ };
398
417
  var findEmojiRowAndColumnById = function findEmojiRowAndColumnById(emojiId) {
418
+ var deletableOnly = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
399
419
  var columnIndex = -1;
400
420
  // for most of cases, it'd be in first emoji row, so should be quite fast to find in real world
401
421
  var rowIndex = virtualItems.findIndex(function (rowItem) {
402
422
  if (rowItem instanceof EmojisRowItem) {
423
+ if (deletableOnly && !rowItem.props.showDelete) {
424
+ return false;
425
+ }
403
426
  // find uploaded emoji in each emoji row
404
427
  columnIndex = rowItem.props.emojis.findIndex(function (emoji) {
405
428
  return emoji.id === emojiId;
@@ -474,6 +497,22 @@ export var EmojiPickerVirtualListInternal = /*#__PURE__*/React.forwardRef(functi
474
497
  useEffect(function () {
475
498
  buildVirtualItems();
476
499
  }, [allEmojiGroups, buildVirtualItems]);
500
+ useEffect(function () {
501
+ var emojiId = emojiToRestoreFocusRef.current;
502
+ if (emojiToDelete || !emojiId || !fg('platform_ally_emoji_fixes_various')) {
503
+ return;
504
+ }
505
+ emojiToRestoreFocusRef.current = undefined;
506
+ // delete is only triggered from deletable emojis (i.e. "Your uploads"), so prefer those rows
507
+ var _findEmojiRowAndColum2 = findEmojiRowAndColumnById(emojiId, true),
508
+ rowIndex = _findEmojiRowAndColum2.rowIndex,
509
+ columnIndex = _findEmojiRowAndColum2.columnIndex;
510
+ if (rowIndex !== -1) {
511
+ var _listRef$current5;
512
+ (_listRef$current5 = listRef.current) === null || _listRef$current5 === void 0 || _listRef$current5.focusEmojiPreservingScroll(rowIndex, columnIndex);
513
+ }
514
+ // eslint-disable-next-line react-hooks/exhaustive-deps
515
+ }, [emojiToDelete]);
477
516
  useEffect(function () {
478
517
  if (categoriesChanged) {
479
518
  onRowsRendered({
@@ -510,7 +549,7 @@ export var EmojiPickerVirtualListInternal = /*#__PURE__*/React.forwardRef(functi
510
549
  onUploadCancelled: onUploadCancelled,
511
550
  onUploadEmoji: onUploadEmoji,
512
551
  onCloseDelete: handleOnCloseDelete,
513
- onDeleteEmoji: onDeleteEmoji,
552
+ onDeleteEmoji: fg('platform_ally_emoji_fixes_various') ? handleOnDeleteEmoji : onDeleteEmoji,
514
553
  onFileChooserClicked: onFileChooserClicked,
515
554
  onOpenUpload: onOpenUpload,
516
555
  onProductivityColorSelected: onProductivityColorSelected,
@@ -242,11 +242,42 @@ export var VirtualList = /*#__PURE__*/React.forwardRef(function (props, ref) {
242
242
  scrollToEmojiAndFocus: function scrollToEmojiAndFocus(rowIndex, columnIndex) {
243
243
  focusEmoji(rowIndex, columnIndex, KeyboardNavigationDirection.Left, true);
244
244
  },
245
+ focusEmojiPreservingScroll: function focusEmojiPreservingScroll(rowIndex, columnIndex) {
246
+ var getEmojiElement = function getEmojiElement() {
247
+ var _virtualistItemsRef$c2;
248
+ return (_virtualistItemsRef$c2 = virtualistItemsRef.current) === null || _virtualistItemsRef$c2 === void 0 ? void 0 : _virtualistItemsRef$c2.querySelector("[data-focus-index=\"".concat(rowIndex, "-").concat(columnIndex, "\"]"));
249
+ };
250
+ var focusEmojiElement = function focusEmojiElement(emojiElement) {
251
+ setEmojisFocus({
252
+ rowIndex: rowIndex,
253
+ columnIndex: columnIndex
254
+ });
255
+ emojiElement.focus({
256
+ preventScroll: true
257
+ });
258
+ };
259
+
260
+ // keep the current scroll position if the emoji is still visible in the list
261
+ var renderedEmojiElement = getEmojiElement();
262
+ if (renderedEmojiElement && isElementVisible(renderedEmojiElement)) {
263
+ focusEmojiElement(renderedEmojiElement);
264
+ return;
265
+ }
266
+
267
+ // otherwise scroll to target rowIndex first to ensure the row is rendered in list.
268
+ rowVirtualizer.scrollToIndex(rowIndex);
269
+ setTimeout(function () {
270
+ var emojiElement = getEmojiElement();
271
+ if (emojiElement) {
272
+ focusEmojiElement(emojiElement);
273
+ }
274
+ }, 100); // 100ms is virtual list scrolling time
275
+ },
245
276
  updateFocusIndex: function updateFocusIndex(rowIndex) {
246
- var _virtualistItemsRef$c2;
277
+ var _virtualistItemsRef$c3;
247
278
  var columnIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
248
279
  // row could be removed from virtual list after scrolling, we'll update emoji cell tabIndex after losing focus
249
- if (!((_virtualistItemsRef$c2 = virtualistItemsRef.current) !== null && _virtualistItemsRef$c2 !== void 0 && _virtualistItemsRef$c2.contains(document.activeElement))) {
280
+ if (!((_virtualistItemsRef$c3 = virtualistItemsRef.current) !== null && _virtualistItemsRef$c3 !== void 0 && _virtualistItemsRef$c3.contains(document.activeElement))) {
250
281
  setEmojisFocus({
251
282
  rowIndex: rowIndex,
252
283
  columnIndex: columnIndex
@@ -17,6 +17,12 @@ type Props = {
17
17
  width: number;
18
18
  };
19
19
  export type ListRef = {
20
+ /**
21
+ * Focus on a emoji in virtual list, only scrolling if the emoji is not currently visible
22
+ * @param rIndex row index of virtual list
23
+ * @param cIndex column index of virtual list
24
+ */
25
+ focusEmojiPreservingScroll: (rIndex: number, cIndex: number) => void;
20
26
  /**
21
27
  * Scroll to a emoji in virtual list and focus on it
22
28
  * @param rIndex row index of virtual list
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/emoji",
3
- "version": "73.6.1",
3
+ "version": "73.6.2",
4
4
  "description": "Fabric emoji React components",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -35,7 +35,7 @@
35
35
  "@atlaskit/afm-i18n-platform-elements-emoji": "2.306.0",
36
36
  "@atlaskit/analytics-next": "^12.6.0",
37
37
  "@atlaskit/browser-apis": "^1.2.0",
38
- "@atlaskit/button": "^25.7.0",
38
+ "@atlaskit/button": "^25.8.0",
39
39
  "@atlaskit/css": "^1.1.0",
40
40
  "@atlaskit/feature-gate-js-client": "^8.0.0",
41
41
  "@atlaskit/form": "^18.3.0",