Skip to content
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

chore: remove combobox useEffect used to trigger handleTextValueChange #1399

Merged
merged 1 commit into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions packages/strapi-design-system/src/Combobox/Combobox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,6 @@ export const ComboboxInput = React.forwardRef<ComboboxInputElement, ComboboxInpu
skipWhen: !internalIsOpen,
});

React.useEffect(() => {
/**
* When the value prop changes "externally" update the text input value too
*/
handleTextValueChange(value || '');

// eslint-disable-next-line react-hooks/exhaustive-deps
}, [value]);

const hintId = `${generatedId}-hint`;
const errorId = `${generatedId}-error`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,6 @@ describe('Combobox', () => {
expect(getByRole('combobox')).toHaveValue('Strawberry 2');
});

it('should correctly change the rendered text value of the combobox when the value prop changes externally', async () => {
const onTextValueChange = jest.fn();
const { rerender } = renderRTL(<Component options={defaultOptions} onTextValueChange={onTextValueChange} />);

expect(onTextValueChange).toHaveBeenCalledTimes(1);
expect(onTextValueChange).toHaveBeenCalledWith('');

rerender(<Component options={defaultOptions} onTextValueChange={onTextValueChange} value="bagel" />);

expect(onTextValueChange).toHaveBeenCalledTimes(2);
expect(onTextValueChange).toHaveBeenCalledWith('bagel');
});

describe('callbacks', () => {
it('should fire onChange only when the value is changed not when the input does', async () => {
const onChange = jest.fn();
Expand Down
Loading