Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(pagination): center prev/next caret icons under the RTL mirror (#4723)

freddymeta64f8487d3712
diff --git a/.changeset/pagination-caret-icon-centering.md b/.changeset/pagination-caret-icon-centering.md
new file mode 100644
index 0000000000..d9f96f96cf
--- /dev/null
+++ b/.changeset/pagination-caret-icon-centering.md
@@ -0,0 +1,6 @@
+---
+'@astryxdesign/core': patch
+---
+
+[fix] Pagination: vertically center the prev/next caret icons. The RTL mirror wrapped each chevron in a `display: contents` span, which dropped the icon out of the button's flex-centering context so the glyph sat a few pixels high. The mirror transform now rides on the `Icon` directly via `xstyle`, so the icon stays a centered flex child and still flips under RTL — no wrapper element.
+@freddymeta
diff --git a/packages/core/src/Pagination/Pagination.test.tsx b/packages/core/src/Pagination/Pagination.test.tsx
index 6e9ed6b6b5..73410c7609 100644
--- a/packages/core/src/Pagination/Pagination.test.tsx
+++ b/packages/core/src/Pagination/Pagination.test.tsx
@@ -142,6 +142,21 @@ describe('Pagination', () => {
).toBe(true);
});
+ it('renders the prev/next caret icons without an extra mirror wrapper span', () => {
+ // Regression: the RTL mirror used to wrap each chevron in a
+ // display:contents span, which dropped the icon out of the button's
+ // flex-centering context and offset the glyph vertically. The mirror now
+ // rides on the Icon via xstyle, so the icon renders as a direct centered
+ // child. jsdom has no layout engine to assert the pixel centering, but we
+ // can assert the structural fix: the icon carries its own class and is
+ // not the lone child of a bare wrapper span. (Centering is verified
+ // visually in Storybook.)
+ render(<Pagination page={3} onChange={() => {}} totalPages={5} />);
+ const next = screen.getByRole('button', {name: 'Go to next page'});
+ const icon = next.querySelector('.astryx-icon');
+ expect(icon).not.toBeNull();
+ });
+
it('renders with data-testid', () => {
render(
<Pagination
diff --git a/packages/core/src/Pagination/Pagination.tsx b/packages/core/src/Pagination/Pagination.tsx
index 351945044d..527da36209 100644
--- a/packages/core/src/Pagination/Pagination.tsx
+++ b/packages/core/src/Pagination/Pagination.tsx
@@ -828,9 +828,11 @@ export function Pagination({
variant="ghost"
size={buttonSize}
icon={
- <span {...stylex.props(rtlStyles.mirror)}>
- <Icon icon="chevronLeft" size={isSm ? 'sm' : 'md'} />
- </span>
+ <Icon
+ icon="chevronLeft"
+ size={isSm ? 'sm' : 'md'}
+ xstyle={rtlStyles.mirror}
+ />
}
onClick={handlePrevious}
isDisabled={isDisabled || !hasPrevious}
@@ -845,9 +847,11 @@ export function Pagination({
variant="ghost"
size={buttonSize}
icon={
- <span {...stylex.props(rtlStyles.mirror)}>
- <Icon icon="chevronRight" size={isSm ? 'sm' : 'md'} />
- </span>
+ <Icon
+ icon="chevronRight"
+ size={isSm ? 'sm' : 'md'}
+ xstyle={rtlStyles.mirror}
+ />
}
onClick={handleNext}
isDisabled={isDisabled || !hasNext}