Skip to content

Commit 5f3b61d

Browse files
avelinelaurkim
andauthored
[Layout] Update Box to support li and tabIndex (#7806)
### WHY are these changes introduced? Supports #7458 ### WHAT is this pull request doing? Update `Box` to support `li` and `tabIndex` Co-authored-by: Lo Kim <[email protected]>
1 parent 23665df commit 5f3b61d

File tree

4 files changed

+1476
-1458
lines changed

4 files changed

+1476
-1458
lines changed

.changeset/two-readers-arrive.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@shopify/polaris': minor
3+
'polaris.shopify.com': patch
4+
---
5+
6+
Added support for `li` and `tabIndex` on `Box`

polaris-react/src/components/Box/Box.scss

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
@import '../../styles/common';
22

3+
.listReset {
4+
list-style-type: none;
5+
margin-block-start: 0;
6+
margin-block-end: 0;
7+
outline: none;
8+
padding-inline-start: 0;
9+
}
10+
311
.Box {
412
@include responsive-props('box', 'padding', 'padding');
513
@include responsive-props(
@@ -112,11 +120,3 @@
112120
.visuallyHidden {
113121
@include visually-hidden;
114122
}
115-
116-
.listReset {
117-
list-style-type: none;
118-
margin-block-start: 0;
119-
margin-block-end: 0;
120-
outline: none;
121-
padding-inline-start: 0;
122-
}

polaris-react/src/components/Box/Box.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919

2020
import styles from './Box.scss';
2121

22-
type Element = 'div' | 'span' | 'section' | 'ul';
22+
type Element = 'div' | 'span' | 'section' | 'ul' | 'li';
2323
type Overflow = 'hidden' | 'scroll';
2424
type Position = 'relative' | 'absolute' | 'fixed' | 'sticky';
2525

@@ -151,9 +151,11 @@ export interface BoxProps extends React.AriaAttributes {
151151
*/
152152
paddingInlineEnd?: Spacing;
153153
/** Aria role */
154-
role?: Extract<React.AriaRole, 'status'>;
154+
role?: Extract<React.AriaRole, 'status' | 'presentation' | 'menu'>;
155155
/** Shadow on box */
156156
shadow?: DepthShadowAlias;
157+
/** Set tab order */
158+
tabIndex?: Extract<React.AllHTMLAttributes<HTMLElement>['tabIndex'], number>;
157159
/** Width of container */
158160
width?: string;
159161
// These could be moved to new layout component(s) in the future
@@ -210,6 +212,7 @@ export const Box = forwardRef<HTMLElement, BoxProps>(
210212
paddingInlineEnd,
211213
role,
212214
shadow,
215+
tabIndex,
213216
width,
214217
visuallyHidden,
215218
position,
@@ -332,6 +335,7 @@ export const Box = forwardRef<HTMLElement, BoxProps>(
332335
ref,
333336
style: sanitizeCustomProperties(style),
334337
role,
338+
tabIndex,
335339
...restProps,
336340
},
337341
children,

0 commit comments

Comments
 (0)