-
Notifications
You must be signed in to change notification settings - Fork 68
LG-4899: getLgIds #2786
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?
LG-4899: getLgIds #2786
Conversation
🦋 Changeset detectedLatest commit: 2a3427b The changes in this PR will be included in the next version bump. This PR includes changesets to release 61 packages
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 |
Size Change: +2.08 kB (+0.14%) Total Size: 1.5 MB
ℹ️ View Unchanged
|
packages/gallery-indicator/src/GalleryIndicator/GalleryIndicator.tsx
Outdated
Show resolved
Hide resolved
|
||
import { Variant } from './MenuItem.types'; | ||
const lgIds = getLgIds(); |
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.
This'll be different if a custom lgid is provided. technically I guess it doesn't matter here though
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.
Noticed 2 common nits:
- Default value set twice
- Calling
useMemo
ongetLgids()
. Not sure that's necessary (were you noticing issues without it?)
@@ -45,7 +45,7 @@ const Checkbox = React.forwardRef( | |||
checked: checkedProp, | |||
className, | |||
darkMode: darkModeProp, | |||
'data-lgid': dataLgId = DEFAULT_LGID_ROOT, | |||
'data-lgid': dataLgId = getLgIds().root, |
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 don't think we even need to set a default here at all. The prop itself isn't used directly, so if the prop is not passed in, we just pass in undefined
to getLgIds
on L66.
I don't see any real issues with this, just that we're calling getLgIds()
twice if there's no prop passed in (it's a cheap function, so no real concerns, but removing it would be technically correct
@@ -26,7 +26,7 @@ describe('CopyButton', () => { | |||
return render( | |||
<CodeContextProvider | |||
// @ts-expect-error - other ids are missing but not needed for test | |||
lgids={{ | |||
lgIds={{ |
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.
Is this testing that a copyButton
with a non-default id can still be queried?
export const DEFAULT_LGID_ROOT = 'lg-button'; | ||
|
||
export const getLgIds = (root: `lg-${string}` = DEFAULT_LGID_ROOT) => { | ||
export const getLgIds = (root: LgIdString = DEFAULT_LGID_ROOT) => { |
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.
Not necessary here, but it might be worth creating a GetLgIdsFunction
function type, and maybe a return type?
type GetLgIdsFunction = (root?: LgIdString) => {
root: LgIdString,
...
}
✍️ Proposed changes
🎟 Jira ticket: Name of ticket
✅ Checklist
For bug fixes, new features & breaking changes
pnpm changeset
and documented my changesFor new components
🧪 How to test changes