carbon-react 133.0.2 → 133.0.4

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.
@@ -139,7 +139,11 @@ export const ButtonToggle = ({
139
139
  onBlur: handleBlur,
140
140
  onClick: handleClick,
141
141
  onKeyDown: handleKeyDown
142
- }, tabbable ? {} : {
142
+ // In Safari non-text input elements do not gain focus on click. To get around this, we have to apply a tab-index of 0 here.
143
+ // This is to allow the ButtonToggle component to be focused when it is the first tabbable element.
144
+ }, tabbable ? {
145
+ tabIndex: 0
146
+ } : {
143
147
  tabIndex: -1
144
148
  }, {
145
149
  allowDeselect: allowDeselect,
@@ -335,7 +335,10 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
335
335
  });
336
336
  }, [childrenList, filterText, getIndexOfMatch, virtualizer]);
337
337
  useEffect(() => {
338
- if (!highlightedValue) {
338
+ // remove the current selected option if the value is cleared
339
+ // this prevents it from remaining highlighted when the list is re-opened
340
+ if ((!highlightedValue || Object.keys(highlightedValue).length === 0) && !isOpen) {
341
+ setCurrentOptionsListIndex(-1);
339
342
  return;
340
343
  }
341
344
  const indexOfMatch = getIndexOfMatch(highlightedValue);
@@ -343,7 +346,7 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
343
346
  return;
344
347
  }
345
348
  setCurrentOptionsListIndex(indexOfMatch);
346
- }, [getIndexOfMatch, highlightedValue]);
349
+ }, [getIndexOfMatch, highlightedValue, isOpen]);
347
350
 
348
351
  // ensure that the currently-selected option is always visible immediately after
349
352
  // it has been changed
@@ -148,7 +148,11 @@ const ButtonToggle = ({
148
148
  onBlur: handleBlur,
149
149
  onClick: handleClick,
150
150
  onKeyDown: handleKeyDown
151
- }, tabbable ? {} : {
151
+ // In Safari non-text input elements do not gain focus on click. To get around this, we have to apply a tab-index of 0 here.
152
+ // This is to allow the ButtonToggle component to be focused when it is the first tabbable element.
153
+ }, tabbable ? {
154
+ tabIndex: 0
155
+ } : {
152
156
  tabIndex: -1
153
157
  }, {
154
158
  allowDeselect: allowDeselect,
@@ -344,7 +344,10 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
344
344
  });
345
345
  }, [childrenList, filterText, getIndexOfMatch, virtualizer]);
346
346
  (0, _react.useEffect)(() => {
347
- if (!highlightedValue) {
347
+ // remove the current selected option if the value is cleared
348
+ // this prevents it from remaining highlighted when the list is re-opened
349
+ if ((!highlightedValue || Object.keys(highlightedValue).length === 0) && !isOpen) {
350
+ setCurrentOptionsListIndex(-1);
348
351
  return;
349
352
  }
350
353
  const indexOfMatch = getIndexOfMatch(highlightedValue);
@@ -352,7 +355,7 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
352
355
  return;
353
356
  }
354
357
  setCurrentOptionsListIndex(indexOfMatch);
355
- }, [getIndexOfMatch, highlightedValue]);
358
+ }, [getIndexOfMatch, highlightedValue, isOpen]);
356
359
 
357
360
  // ensure that the currently-selected option is always visible immediately after
358
361
  // it has been changed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "133.0.2",
3
+ "version": "133.0.4",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",