Skip to content

Commit

Permalink
Update the IndexTable component to prevent a scrollbar flash (#11817)
Browse files Browse the repository at this point in the history
### WHY are these changes introduced?

The scrollbar in `IndexTable`  initially shows and then hides on render.

🌀 [Spin
link](https://admin.web.index-table-test.sam-rose.us.spin.dev/store/shop1)

**Before**


https://github.com/Shopify/polaris/assets/11774595/cc494771-cebb-4969-bed3-6d017ecf1c97

**After**

No flash of scrollbar.

### WHAT is this pull request doing?

This updates the default state of the scrollbar to be hidden and updates
the `SCROLL_BAR_PADDING` since the inline padding has been increased
from `--p-space-050` to `--p-space-200`).

### 🎩 checklist

- [ ] Tested a
[snapshot](https://github.com/Shopify/polaris/blob/main/documentation/Releasing.md#-snapshot-releases)
- [ ] Tested on
[mobile](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md#cross-browser-testing)
- [ ] Tested on [multiple
browsers](https://help.shopify.com/en/manual/shopify-admin/supported-browsers)
- [ ] Tested for
[accessibility](https://github.com/Shopify/polaris/blob/main/documentation/Accessibility%20testing.md)
- [ ] Updated the component's `README.md` with documentation changes
- [ ] [Tophatted
documentation](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting%20documentation.md)
changes in the style guide

Co-authored-by: Marc Thomas <marc.thomas@shopify.com>
  • Loading branch information
sam-b-rose and mrcthms committed Apr 4, 2024
1 parent 2a2f635 commit 936765c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/tricky-beans-fold.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/polaris': patch
---

[IndexTable] Initially hide the scrollbar and update scrollbar padding
5 changes: 2 additions & 3 deletions polaris-react/src/components/IndexTable/IndexTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export interface TableHeadingRect {
offsetLeft: number;
}

const SCROLL_BAR_PADDING = 4;
const SCROLL_BAR_PADDING = 16;
const SCROLL_BAR_DEBOUNCE_PERIOD = 300;

function IndexTableBase({
Expand Down Expand Up @@ -196,8 +196,7 @@ function IndexTableBase({

const [tableInitialized, setTableInitialized] = useState(false);
const [stickyWrapper, setStickyWrapper] = useState<HTMLElement | null>(null);
const [hideScrollContainer, setHideScrollContainer] =
useState<boolean>(false);
const [hideScrollContainer, setHideScrollContainer] = useState<boolean>(true);

const tableHeadings = useRef<HTMLElement[]>([]);
const stickyTableHeadings = useRef<HTMLElement[]>([]);
Expand Down

0 comments on commit 936765c

Please sign in to comment.