carbon-react 124.4.0 → 124.4.1

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.
@@ -184,6 +184,9 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
184
184
  const lastOptionIndex = findLastIndex(childrenList, child => /*#__PURE__*/React.isValidElement(child) && (child.type === Option || child.type === OptionRow));
185
185
  const getNextHighlightableItemIndex = useCallback((key, indexOfHighlighted) => {
186
186
  const lastIndex = lastOptionIndex;
187
+ if (lastIndex === -1) {
188
+ return -1;
189
+ }
187
190
  let nextIndex = getNextIndexByKey(key, indexOfHighlighted, lastIndex, isLoading);
188
191
  const nextElement = childrenList[nextIndex];
189
192
  if ( /*#__PURE__*/React.isValidElement(nextElement) && nextElement.type !== Option && nextElement.type !== OptionRow) {
@@ -201,7 +204,7 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
201
204
  currentIndex = indexOfHighlighted;
202
205
  }
203
206
  const nextIndex = getNextHighlightableItemIndex(key, currentIndex);
204
- if (currentIndex === nextIndex) {
207
+ if (nextIndex === -1 || currentIndex === nextIndex) {
205
208
  return;
206
209
  }
207
210
  const {
@@ -282,10 +285,10 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
282
285
  const element = event.target;
283
286
 
284
287
  /* istanbul ignore else */
285
- if (onListScrollBottom && element.scrollHeight - element.scrollTop === element.clientHeight) {
288
+ if (isOpen && onListScrollBottom && element.scrollHeight - element.scrollTop === element.clientHeight) {
286
289
  onListScrollBottom();
287
290
  }
288
- }, [onListScrollBottom]);
291
+ }, [onListScrollBottom, isOpen]);
289
292
  useEffect(() => {
290
293
  const keyboardEvent = "keydown";
291
294
  const listElement = listContainerRef.current;
@@ -322,10 +325,6 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
322
325
  }
323
326
  setCurrentOptionsListIndex(indexOfMatch);
324
327
  virtualizer.scrollToIndex(indexOfMatch, SCROLL_OPTIONS);
325
- // TODO: is there a better way than calling handleListScroll manually?
326
- handleListScroll({
327
- target: listContainerRef.current
328
- });
329
328
  }, [getIndexOfMatch, highlightedValue, virtualizer, handleListScroll, listContainerRef]);
330
329
  useEffect(() => {
331
330
  if (isLoading && currentOptionsListIndex === lastOptionIndex && lastOptionIndex > -1) {
@@ -193,6 +193,9 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
193
193
  const lastOptionIndex = (0, _findLastIndex.default)(childrenList, child => /*#__PURE__*/_react.default.isValidElement(child) && (child.type === _option.default || child.type === _optionRow.default));
194
194
  const getNextHighlightableItemIndex = (0, _react.useCallback)((key, indexOfHighlighted) => {
195
195
  const lastIndex = lastOptionIndex;
196
+ if (lastIndex === -1) {
197
+ return -1;
198
+ }
196
199
  let nextIndex = (0, _getNextIndexByKey.default)(key, indexOfHighlighted, lastIndex, isLoading);
197
200
  const nextElement = childrenList[nextIndex];
198
201
  if ( /*#__PURE__*/_react.default.isValidElement(nextElement) && nextElement.type !== _option.default && nextElement.type !== _optionRow.default) {
@@ -210,7 +213,7 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
210
213
  currentIndex = indexOfHighlighted;
211
214
  }
212
215
  const nextIndex = getNextHighlightableItemIndex(key, currentIndex);
213
- if (currentIndex === nextIndex) {
216
+ if (nextIndex === -1 || currentIndex === nextIndex) {
214
217
  return;
215
218
  }
216
219
  const {
@@ -291,10 +294,10 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
291
294
  const element = event.target;
292
295
 
293
296
  /* istanbul ignore else */
294
- if (onListScrollBottom && element.scrollHeight - element.scrollTop === element.clientHeight) {
297
+ if (isOpen && onListScrollBottom && element.scrollHeight - element.scrollTop === element.clientHeight) {
295
298
  onListScrollBottom();
296
299
  }
297
- }, [onListScrollBottom]);
300
+ }, [onListScrollBottom, isOpen]);
298
301
  (0, _react.useEffect)(() => {
299
302
  const keyboardEvent = "keydown";
300
303
  const listElement = listContainerRef.current;
@@ -331,10 +334,6 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
331
334
  }
332
335
  setCurrentOptionsListIndex(indexOfMatch);
333
336
  virtualizer.scrollToIndex(indexOfMatch, SCROLL_OPTIONS);
334
- // TODO: is there a better way than calling handleListScroll manually?
335
- handleListScroll({
336
- target: listContainerRef.current
337
- });
338
337
  }, [getIndexOfMatch, highlightedValue, virtualizer, handleListScroll, listContainerRef]);
339
338
  (0, _react.useEffect)(() => {
340
339
  if (isLoading && currentOptionsListIndex === lastOptionIndex && lastOptionIndex > -1) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "124.4.0",
3
+ "version": "124.4.1",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",