-
Notifications
You must be signed in to change notification settings - Fork 658
feat: implement ADR-023 Part 1 #7724
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
abfe9c4
6381280
091de76
32d4062
c7c0da7
4cf2494
2962363
3f92c21
273f681
8c38035
8c3d244
8ca6eac
ddca738
6f96ebd
17f2bf0
ff94d66
79e42d4
b05df83
db67cc2
e71ce27
f2b0a1f
e94fe52
8c886da
76bb50d
bba65c1
9aaead8
8429e82
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| --- | ||
| '@primer/react': minor | ||
| --- | ||
|
|
||
| Add stable `data-component` selectors to multiple components following ADR-023: | ||
|
|
||
| - **ActionBar** | ||
| - **ActionList** and friends | ||
| - **Button** | ||
| - **FilteredActionList** and friends | ||
| - **Link** | ||
| - **LinkButton** | ||
| - **Pagination** | ||
| - **SelectPanel** and friends | ||
| - **Table** and friends | ||
| - **TextInput** | ||
| - **TextInputwithTokens** | ||
| - **TooltipV2** | ||
|
|
||
| This enables consumers to query and test components using stable selectors like `[data-component="Table.Row"]`. | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -353,7 +353,7 @@ export const ActionBar: React.FC<React.PropsWithChildren<ActionBarProps>> = prop | |||||
|
|
||||||
| return ( | ||||||
| <ActionBarContext.Provider value={{size, isVisibleChild}}> | ||||||
| <div ref={navRef} className={clsx(className, styles.Nav)} data-flush={flush}> | ||||||
| <div ref={navRef} className={clsx(className, styles.Nav)} data-component="ActionBar" data-flush={flush}> | ||||||
| <div | ||||||
| ref={listRef} | ||||||
| role="toolbar" | ||||||
|
|
@@ -532,7 +532,7 @@ export const ActionBarGroup = forwardRef(({children}: React.PropsWithChildren, f | |||||
|
|
||||||
| return ( | ||||||
| <ActionBarGroupContext.Provider value={{groupId: id}}> | ||||||
| <div className={styles.Group} ref={ref}> | ||||||
| <div className={styles.Group} data-component="ActionBar.Group" ref={ref}> | ||||||
| {children} | ||||||
| </div> | ||||||
| </ActionBarGroupContext.Provider> | ||||||
|
|
@@ -571,7 +571,14 @@ export const ActionBarMenu = forwardRef( | |||||
| return ( | ||||||
| <ActionMenu anchorRef={ref} open={menuOpen} onOpenChange={setMenuOpen}> | ||||||
| <ActionMenu.Anchor> | ||||||
| <IconButton variant="invisible" aria-label={ariaLabel} icon={icon} {...props} /> | ||||||
| <IconButton | ||||||
| variant="invisible" | ||||||
| aria-label={ariaLabel} | ||||||
| icon={icon} | ||||||
| {...props} | ||||||
| // overriding IconButton's data-component so that the ActionBar's "More Menu" Icon can be targetted specifically | ||||||
|
||||||
| // overriding IconButton's data-component so that the ActionBar's "More Menu" Icon can be targetted specifically | |
| // overriding IconButton's data-component so that the ActionBar's "More Menu" Icon can be targeted specifically |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be:
- ActionBar.MenuIconButton
- ActionBar.Menu
- ActionBar.Menu.IconButton
?
I feel like this is the IconButton that belongs to the Menu that is a subcomponent of ActionBar, which is why ActionBar.Menu.IconButton makes sense to me 🤔. ActionBar.Menu seems disingenuous because really this is not the menu itself, just the Icon trigger. But I could see the case for ActionBar.MenuIconButton
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I vote for ActionBar.Menu.IconButton too!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tl;dr: both ActionBar.MenuIconButton and ActionBar.Menu.IconButton are fine, i like one more than the other
ActionBar.Menu👎 that's for the menu, not the buttonActionBar.Menu.IconButtonit's fine, but the double dots feels weird, idk why. Maybe becauseActionBar.Menuis actually a shorthand forActionMenu... butActionBar.ActionMenu.IconButtonfeels worse for some reason.ActionBar.MenuIconButton: 👍 I like this the most. consistent pattern everywhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmmmmm, I know i'm being very inconsistent with my feeling or taste™, but i like ActionList.Item.Label there because ActionList.Item is where you would put your className 🤔
❌ bad:
<ActionList>
<ActionList.Item><span className={styles.myLabel}>label</span></ActionList.Item>
</ActionList>
<style>
.myLabel {
font-weight: bold
}
</style>✅ good:
<ActionList>
<ActionList.Item className={styles.myActionListItem}>label</ActionList.Item>
</ActionList>
<style>
// with direct data-component, good!:
.myActionListItem [data-component="ActionList.Item.Label"] {
font-weight: bold
}
</style>I think I was wrong about ActionBar.Menu.IconButton. If ActionBar.Menu is part of the public API, then ActionBar.Menu.IconButton should be the better choice.
Do you mind also including Pagination and SelectPanel in this PR? I think those are the most opaque components, once we go through them, all the rest will be straightforward.

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Component name casing:
TextInputwithTokensshould beTextInputWithTokensto match the exported component name.