Skip to content

Commit

Permalink
fix(chrome): provide missing useId container dependency for Sheet
Browse files Browse the repository at this point in the history
… component (#1981)
  • Loading branch information
jzempel authored Dec 2, 2024
1 parent 2c2c590 commit 2aba142
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 4 deletions.
108 changes: 108 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/chrome/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"sideEffects": false,
"types": "dist/typings/index.d.ts",
"dependencies": {
"@zendeskgarden/container-utilities": "^2.0.0",
"@zendeskgarden/react-buttons": "^9.2.0",
"dom-helpers": "^5.2.1",
"polished": "^4.3.1",
Expand Down
6 changes: 2 additions & 4 deletions packages/chrome/src/elements/sheet/Sheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import React, { useRef, useMemo, useState } from 'react';
import PropTypes from 'prop-types';
import { useUIDSeed } from 'react-uid';
import { useId } from '@zendeskgarden/container-utilities';
import { mergeRefs } from 'react-merge-refs';

import { ISheetProps, PLACEMENT } from '../../types';
Expand All @@ -29,10 +29,8 @@ const SheetComponent = React.forwardRef<HTMLElement, ISheetProps>(
ref
) => {
const sheetRef = useRef<HTMLElement>(null);

const seed = useUIDSeed();
const [isCloseButtonPresent, setIsCloseButtonPresent] = useState<boolean>(false);
const idPrefix = useMemo<string>(() => id || seed(`sheet_${PACKAGE_VERSION}`), [id, seed]);
const idPrefix = useId(id);
const titleId = `${idPrefix}--title`;
const descriptionId = `${idPrefix}--description`;

Expand Down
2 changes: 2 additions & 0 deletions packages/chrome/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ export interface INavItemTextProps extends HTMLAttributes<HTMLSpanElement> {
}

export interface ISheetProps extends HTMLAttributes<HTMLElement> {
/** Identifies the sheet */
id?: string;
/** Opens the sheet */
isOpen?: boolean;
/** Determines whether animation for opening and closing the sheet is used */
Expand Down

0 comments on commit 2aba142

Please sign in to comment.