Skip to content

Commit

Permalink
fix(components): fix incorrect usage of useid (#6491)
Browse files Browse the repository at this point in the history
  • Loading branch information
gribnoysup authored Nov 14, 2024
1 parent cd2ec02 commit 9908bb9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { palette } from '@leafygreen-ui/palette';
import { rgba } from 'polished';
import { useDarkMode } from '../hooks/use-theme';
import { useHotkeys } from '../hooks/use-hotkeys';
import { useId } from '@react-aria/utils';

const borderRadius = spacing[2];

Expand Down Expand Up @@ -162,7 +161,7 @@ function InteractivePopover({

useHotkeys('Escape', onClose, { enabled: open }, [onClose]);

const closeButtonId = useId('close-button-id');
const closeButtonId = 'close-button-id';

return trigger({
onClick: onClickTrigger,
Expand Down
8 changes: 4 additions & 4 deletions packages/compass-components/src/hooks/use-sort.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('use-sort', function () {
expect(
screen
.getByRole('button', {
name: /title/i,
name: 'Sort by',
})
.getAttribute('aria-disabled')
).to.equal('true');
Expand All @@ -70,7 +70,7 @@ describe('use-sort', function () {
// Opens dropdown
userEvent.click(
screen.getByRole('button', {
name: /title/i,
name: 'Sort by',
}),
undefined,
{
Expand Down Expand Up @@ -111,7 +111,7 @@ describe('use-sort', function () {
// Opens dropdown
userEvent.click(
screen.getByRole('button', {
name: /title/i,
name: 'Sort by',
}),
undefined,
{
Expand Down Expand Up @@ -141,7 +141,7 @@ describe('use-sort', function () {
// Opens dropdown
userEvent.click(
screen.getByRole('button', {
name: /title/i,
name: 'Sort by',
}),
undefined,
{
Expand Down
2 changes: 1 addition & 1 deletion packages/compass-components/src/hooks/use-sort.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function useSortControls<T extends string>(
items: readonly { name: T; label: string }[],
options?: SortOptions
): [React.ReactElement, SortState<Unwrap<typeof items>['name']>] {
const labelId = useId('Sort by');
const labelId = 'sort-by';
const controlId = useId();

const [sortState, dispatch] = useReducer(
Expand Down

0 comments on commit 9908bb9

Please sign in to comment.