Skip to content

Commit

Permalink
fix(Autocomplete): make input_value react to prop change (#3706)
Browse files Browse the repository at this point in the history
  • Loading branch information
joakbjerk authored Jun 14, 2024
1 parent edd6214 commit 641e5e7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
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.

0 comments on commit 641e5e7

Please sign in to comment.