@atlassian/aui 9.6.1 → 9.6.3

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@atlassian/aui",
3
3
  "description": "Atlassian User Interface library",
4
- "version": "9.6.1",
4
+ "version": "9.6.3",
5
5
  "author": "Atlassian Pty Ltd.",
6
6
  "homepage": "https://aui.atlassian.com",
7
7
  "license": "Apache-2.0",
@@ -798,7 +798,12 @@ var dropdownPrototype = {
798
798
  // the dropdown is closed.
799
799
  if (previousLayout && focusTrigger) {
800
800
  doIfTrigger(previousLayout.el, (trigger) => {
801
- trigger.focus();
801
+ // Delay focusing to allow things to settle; otherwise
802
+ // Skatejs's MutationObserver kicks in and opens the dropdown
803
+ // again.
804
+ setTimeout(() => {
805
+ trigger.focus();
806
+ }, 0)
802
807
  setTrigger(previousLayout.el, null);
803
808
  });
804
809
  }
@@ -0,0 +1 @@
1
+ console.debug('AUI import for WRM I18n not loaded');
@@ -1,3 +1,5 @@
1
+ // Import the I18n system from the WRM, webpack handles this
2
+ import 'wrmI18n';
1
3
  import format from './format';
2
4
  import { putOnI18nIfAbsent } from './internal/globalize';
3
5
  import keys from './internal/i18n/aui';
@@ -39,34 +39,85 @@ $.fn.auiSelect2 = function (first) {
39
39
  updatedArgs = arguments;
40
40
  }
41
41
 
42
+ const options = updatedArgs[0];
43
+
44
+ /**
45
+ * AUI-5464: after the upgrade to select2 v3.5.4, custom error handling stopped
46
+ * working, as the `ajax.params.error` function is overriden by select2, and
47
+ * there is no alternative to this...
48
+ *
49
+ * This is a workaround for creating an array of ajax error handlers that will
50
+ * contain the default handler and the custom ones, which is supported starting
51
+ * from jQuery v1.5: http://api.jquery.com/jquery.ajax/
52
+ *
53
+ * Please note this issue is fixed starting from select2 v4, though the data format
54
+ * is different.
55
+ *
56
+ * @see https://atlassian.slack.com/archives/CFGN5350T/p1686741137056489
57
+ */
58
+ if (options.ajax && options.ajax.params && options.ajax.params.error) {
59
+ let customErrorHandlers = options.ajax.params.error;
60
+ if (!Array.isArray(customErrorHandlers)) {
61
+ customErrorHandlers = [customErrorHandlers];
62
+ }
63
+ let originalTransport = options.ajax.transport;
64
+ if (!originalTransport) {
65
+ originalTransport = originalSelect2.ajaxDefaults.transport
66
+ }
67
+
68
+ const newTransport = function(...args) {
69
+ args[0].error = [args[0].error, ...customErrorHandlers];
70
+ return originalTransport(...args);
71
+ };
72
+
73
+ options.ajax.transport = newTransport;
74
+ }
75
+
42
76
  const result = originalSelect2.apply(this, updatedArgs);
43
77
  const select2Instance = this;
44
- const searchLabel = updatedArgs[0].searchLabel;
78
+ const searchLabel = options.searchLabel;
45
79
 
46
80
  select2Instance.on('select2-open', function () {
47
81
  const $selectInput = $(this);
48
82
 
49
- if (updatedArgs[0].multiple || $selectInput.attr('multiple')) {
83
+ if (options.multiple || $selectInput.attr('multiple')) {
50
84
  // This is a multi-select, exiting
51
85
  return;
52
86
  }
53
87
 
54
- const $selectDropdown = $selectInput.select2('dropdown')
88
+ const $selectDropdown = $selectInput.select2('dropdown');
55
89
 
56
90
  if (searchLabel) {
57
91
  $selectDropdown.find('.select2-search label').text(searchLabel);
58
92
  }
93
+ });
94
+
95
+ select2Instance.on('select2-close', function () {
96
+ const $selectInput = $(this);
97
+ $selectInput.removeData('was-ariadescribedby-cleared');
98
+ });
99
+
100
+ select2Instance.on('select2-loaded', function () {
101
+ const $selectInput = $(this);
102
+ const wasAriaDescribedByCleared = $selectInput.data('was-ariadescribedby-cleared');
103
+
104
+ if (options.multiple || $selectInput.attr('multiple') || wasAriaDescribedByCleared) {
105
+ return;
106
+ }
107
+
108
+ const $selectDropdown = $selectInput.select2('dropdown');
59
109
 
60
110
  // AUI-5461: when single select dropdown opens up, the first option is
61
111
  // instantly focused, making SRs announce it, while skipping the search field
62
112
  $selectDropdown.find('.select2-search .select2-input').attr('aria-activedescendant', '');
113
+ $selectInput.data('was-ariadescribedby-cleared', true);
63
114
  });
64
115
 
65
116
  select2Instance.on('select2-focus', function () {
66
117
  const $selectInput = $(this);
67
118
  const $container = $selectInput.parent().find('.select2-container');
68
119
 
69
- if (updatedArgs[0].multiple || $selectInput.attr('multiple')) {
120
+ if (options.multiple || $selectInput.attr('multiple')) {
70
121
  if (searchLabel) {
71
122
  $container.find('.select2-search-field label').text(searchLabel);
72
123
  }