21427: modified visibility map check Arvados-DCO-1.1-Signed-off-by: Lisa Knox <lisa...
[arvados.git] / services / workbench2 / src / components / multiselect-toolbar / ms-toolbar-overflow-wrapper.tsx
index 1f683b60131cfce45fa105a668a4e31b995a3ac8..32f977e1a4e772004fb2b2d09dc31a146041fed9 100644 (file)
@@ -53,6 +53,7 @@ export const IntersectionObserverWrapper = withStyles(styles)((props: WrapperPro
         const updatedEntries: Record<string, boolean> = {};
         entries.forEach((entry) => {
             const targetid = entry.target.dataset.targetid as string;
+            //if true, the element is visible
             if (entry.isIntersecting) {
                 updatedEntries[targetid] = true;
             } else {
@@ -67,8 +68,9 @@ export const IntersectionObserverWrapper = withStyles(styles)((props: WrapperPro
         }));
     };
 
+    //ensures that the last element is always visible if the second to last is visible
     useEffect(() => {
-        if ((prevNumHidden.current === 2 || prevNumHidden.current === 0) && numHidden === 1) {
+        if ((prevNumHidden.current > 1 || prevNumHidden.current === 0) && numHidden === 1) {
             setVisibilityMap((prev) => ({
                 ...prev,
                 [lastEntryId]: true,