data-component adr part 2#7776
Conversation
🦋 Changeset detectedLatest commit: 3b8e25d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
…data-component to Dialog.tsx while I'm at it
|
👋 Hi from github/github-ui! Your integration PR is ready: https://github.com/github/github-ui/pull/20172 |
| 'aria-label'?: string | ||
| } | ||
|
|
||
| const BreadcrumbsMenuItem = React.forwardRef<HTMLDetailsElement, BreadcrumbsMenuItemProps>( |
There was a problem hiding this comment.
should this element have a data-component as well?
There was a problem hiding this comment.
Not sure; it's not exported so I didn't think so. Do you think it should?
There was a problem hiding this comment.
I vote we add it, your call though!
| return React.Children.map(children, child => ( | ||
| <li className={classes.ItemWrapper} data-component="Breadcrumbs.ItemWrapper"> | ||
| {child} | ||
| </li> |
There was a problem hiding this comment.
I don't think we need a wrapper data-component here
| Label: CheckboxOrRadioGroupLabel, | ||
| Validation: CheckboxOrRadioGroupValidation, |
There was a problem hiding this comment.
Should Label, Validation have data-component as well?
There was a problem hiding this comment.
Sure! Would you suggest including Caption too in that case?
These all have to pass through CheckboxOrRadioGroup etc. too, which are also used by RadioGroup and its sub-components. Let me know what pattern you think would be best for that so [data-component="CheckboxGroup"] and [data-component="RadioGroup"] still work separately.
For this PR, I wonder if it would be better to just take CheckboxGroup out for now until I can open a new one with RadioGroup too? I don't really want to make this one even bigger 🤔
There was a problem hiding this comment.
yeah, Caption too!. I think similar to the way you did CheckboxOrRadioGroup, maybe take the parentName as the prop?
| // @ts-expect-error inputProp needs a non nullable ref | ||
| <input | ||
| {...inputProps} | ||
| data-component={dataComponent ?? 'Checkbox'} |
There was a problem hiding this comment.
why does this need to take in dataComponent as a prop?
There was a problem hiding this comment.
I was trying to make sure [data-component=FilteredActionList.SelectAllCheckbox] (and possibly others that we haven't run into yet) could still be used without being overridden by [data-component=Checkbox]. Let me know if you have a different suggestion!
| <span {...counterProps} className={clsx(className, classes.CounterLabel)}> | ||
| <span | ||
| {...counterProps} | ||
| data-component={dataComponent ?? 'CounterLabel'} |
There was a problem hiding this comment.
why does this need to take in dataComponent as a prop?
There was a problem hiding this comment.
I was trying to make sure [data-component=ButtonCounter] could still be used without being overridden by [data-component=CounterLabel]. Let me know if you have a different suggestion!
| <ScrollableRegion | ||
| aria-labelledby={dialogLabelId} | ||
| className={classes.DialogOverflowWrapper} | ||
| data-component="Dialog.OverflowWrapper" | ||
| > |
| <Dialog.Header> | ||
| <div className={classes.HeaderInner}> | ||
| <div className={classes.HeaderContent}> | ||
| <div className={classes.HeaderContent} data-component="Dialog.Header.Content"> |
| <> | ||
| {buttons.map((dialogButtonProps, index) => { | ||
| const {content, buttonType = 'default', autoFocus = false, ...buttonProps} = dialogButtonProps | ||
| return ( | ||
| <Button | ||
| key={index} | ||
| {...buttonProps} | ||
| // 'normal' value is equivalent to 'default', this is used for backwards compatibility | ||
| variant={buttonType === 'normal' ? 'default' : buttonType} | ||
| // @ts-expect-error it needs a non nullable ref | ||
| ref={autoFocus && autoFocusCount === 0 ? (autoFocusCount++, autoFocusRef) : null} | ||
| > | ||
| {content} | ||
| </Button> | ||
| ) | ||
| })} | ||
| </> | ||
| ) | ||
| } |
There was a problem hiding this comment.
this is such a weird component 😢.
Are we confident [data-component="Dialog] [data-component="Button] will only match these? if not let's override the data-component for the button so that we have a way to reach only these 🤷🏽
| expect(getByRole('dialog')).not.toHaveAttribute('data-has-footer') | ||
| }) | ||
|
|
||
| it('renders data-component attribute', () => { |
There was a problem hiding this comment.
can we add tests for the subcomponents here as well
Relates to https://github.com/github/primer/issues/6497
Changelog
New
Add data-component attributes and associated tests for Blankslate, BranchName, Breadcrumbs, ButtonGroup, Checkbox, CheckboxGroup, CircleBadge, ConfirmationDialog, and CounterLabel.
Rollout strategy
Testing & Reviewing
Merge checklist