Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Commit

Permalink
Review Comments Implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
AH106586Harika authored and AH106586Harika committed Oct 19, 2023
1 parent 1bd9327 commit 468dbd3
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ This component requires the following peer dependencies be installed in your app

<!-- AUTO-GENERATED-CONTENT:END -->

## Implementation Notes:
The Form-Field component must be composed inside the [Base][1] component with a locale in order for it to load the correct translation strings.

[1]: https://engineering.cerner.com/terra-core/components/terra-base/base/base

## Usage

```jsx
Expand All @@ -62,3 +67,26 @@ import DropdownButton, { Item } from 'terra-dropdown-button';

## Item Props
<ItemPropsTable />

## Testing

Terra Alert uses `uuid` which changes the component's description id dynamically. To mock the return value with the Jest testing library, `jest.spyOn` can be used.

If Enzyme `shallow` is being used for the tests then the mock may not be required depending on the depth of the returned wrapper. However, if `mount` is used then `uuid` should be mocked as shown below:

```js
import { v4 as uuidv4 } from 'uuid';

let mockSpyUuid;

// using a variable may result in failures. For best results, mock return value.
beforeAll(() => {
mockSpyUuid = jest.spyOn(uuidv4, 'v4').mockReturnValue('00000000-0000-0000-0000-000000000000');
});

// restore the mock
afterAll(() => {
mockSpyUuid.mockRestore();
});

```
2 changes: 1 addition & 1 deletion packages/terra-dropdown-button/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Unreleased
* Added
* Added aria-haspoup and aria-controls attributes for dropdown button.
* Added 'aria-haspoup' and 'aria-controls' attributes for dropdown button.

## 1.36.0 - (August 8, 2023)

Expand Down
5 changes: 3 additions & 2 deletions packages/terra-dropdown-button/src/_Dropdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const Dropdown = ({
requestClose, isOpen, targetRef, children, width, refCallback, buttonRef, getSelectedOptionText, ...customProps
}) => {
const buttonFocused = useRef(false);
const { menuId, buttonId } = customProps;
useEffect(() => {
// added this change to bring focus back to button when dropdown list is closed.
if (buttonFocused.current && buttonRef) {
Expand Down Expand Up @@ -76,8 +77,8 @@ const Dropdown = ({
width={width}
refCallback={refCallback}
getSelectedOptionText={getSelectedOptionText}
menuId={customProps.menuId}
buttonId={customProps.buttonId}
menuId={menuId}
buttonId={buttonId}
>
{children}
</DropdownList>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ describe('Dropdown Button', () => {
</DropdownButton>
</ThemeContextProvider>,
);
const dropDownButtonId = wrapper.find('#dropDown');
expect(dropDownButtonId.exists()).toBe(true);
expect(wrapper).toMatchSnapshot();
});

Expand Down

0 comments on commit 468dbd3

Please sign in to comment.