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

fix(Autocomplete): make input_value react to prop change #3706

Merged
merged 3 commits into from
Jun 14, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,6 @@ class AutocompleteInstance extends React.PureComponent {

if (
props.input_value !== 'initval' &&
typeof state.inputValue === 'undefined' &&
props.input_value?.length > 0
) {
state.inputValue = props.input_value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3227,6 +3227,18 @@ describe('Autocomplete component', () => {
expect(ref.current.getAttribute('id')).toBe('unique')
expect(ref.current.tagName).toBe('INPUT')
})

it('should change input value when prop changes', () => {
const { rerender } = render(<Autocomplete input_value="first value" />)

const input = document.querySelector('input')

expect(input.value).toBe('first value')

rerender(<Autocomplete input_value="second value" />)

expect(input.value).toBe('second value')
})
})

describe('Autocomplete markup', () => {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading