- {visibleItems?.length > 0 &&
- visibleItems.map((item, index) => {
- // Render custom components
- if (tagComponent) {
- return getCustomComponent(item, tagComponent);
- } else {
- const { id, label, tagType, onClose, filter, ...other } = item;
- // If there is no template prop, then render items as Tags
- return (
-
itemRefHandler(id, node)} key={id}>
- {typeof onClose === 'function' || filter ? (
- handleTagOnClose(onClose, index)}
- text={label}
- />
- ) : (
-
- {label}
-
- )}
-
- );
- }
+
+ {visibleItems.map((item, index) => {
+ const { id, label, tagType, onClose, filter, ...other } = item;
+ return (
+
{
+ itemRefHandler(id, node);
+ }}
+ key={id}
+ >
+ {tagComponent ? (
+ getCustomComponent(item, tagComponent)
+ ) : typeof onClose === 'function' || filter ? (
+ handleTagOnClose(onClose, index)}
+ text={label}
+ />
+ ) : (
+
+ {label}
+
+ )}
+
+ );
})}
-
-
- {overflowItems?.length > 0 && (
- <>
+ {overflowItems.length > 0 && (
+
- >
+
)}
-
+
);
}
diff --git a/packages/ibm-products/src/global/js/hooks/useOverflowItems.ts b/packages/ibm-products/src/global/js/hooks/useOverflowItems.ts
new file mode 100644
index 0000000000..f18955a9e3
--- /dev/null
+++ b/packages/ibm-products/src/global/js/hooks/useOverflowItems.ts
@@ -0,0 +1,99 @@
+/**
+ * Copyright IBM Corp. 2025, 2025
+ *
+ * This source code is licensed under the Apache-2.0 license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+
+import { RefObject, useRef, useState } from 'react';
+import { useResizeObserver } from './useResizeObserver';
+
+type Item = {
+ id: string;
+};
+
+export const useOverflowItems =