Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/nasty-pianos-shout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/polaris': patch
---

Fix bulk actions not visible on IndexTable on small screens
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Fix bulk actions not visible on IndexTable on small screens
Fixed `IndexTable` bulk action visibility on small screens

18 changes: 16 additions & 2 deletions polaris-react/src/components/IndexTable/IndexTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ function IndexTableBase({
const [stickyWrapper, setStickyWrapper] = useState<HTMLElement | null>(null);
const [hideScrollContainer, setHideScrollContainer] =
useState<boolean>(false);
const [smallScreen, setSmallScreen] = useState(isSmallScreen());

const tableHeadings = useRef<HTMLElement[]>([]);
const stickyTableHeadings = useRef<HTMLElement[]>([]);
Expand Down Expand Up @@ -250,6 +251,13 @@ function IndexTableBase({
handleCanScrollRight();
}, [handleCanScrollRight]);

const handleIsSmallScreen = useCallback(() => {
const newSmallScreen = isSmallScreen();
if (smallScreen !== newSmallScreen) {
setSmallScreen(newSmallScreen);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove the conditional here because states only get updated if the value passed to the setter method is not the same as the current value.

Suggested change
const newSmallScreen = isSmallScreen();
if (smallScreen !== newSmallScreen) {
setSmallScreen(newSmallScreen);
}
setSmallScreen(isSmallScreen());

}, [smallScreen]);

const handleResize = useCallback(() => {
// hide the scrollbar when resizing
scrollBarElement.current?.style.setProperty(
Expand All @@ -260,7 +268,13 @@ function IndexTableBase({
resizeTableHeadings();
debounceResizeTableScrollbar();
handleCanScrollRight();
}, [debounceResizeTableScrollbar, resizeTableHeadings, handleCanScrollRight]);
handleIsSmallScreen();
}, [
resizeTableHeadings,
debounceResizeTableScrollbar,
handleCanScrollRight,
handleIsSmallScreen,
]);

const handleScrollContainerScroll = useCallback(
(canScrollLeft, canScrollRight) => {
Expand Down Expand Up @@ -467,7 +481,7 @@ function IndexTableBase({
<div className={bulkActionClassNames} data-condensed={condensed}>
{loadingMarkup}
<BulkActions
smallScreen={condensed}
smallScreen={smallScreen}
label={i18n.translate('Polaris.IndexTable.selected', {
selectedItemsCount: selectedItemsCountLabel,
})}
Expand Down