-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[InputUnstyled] Fix externally provided
inputRef
is ignored (#35807)
Co-authored-by: Zeeshan Tamboli <[email protected]>
- Loading branch information
1 parent
3bde8db
commit 4aeda27
Showing
4 changed files
with
32 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import * as React from 'react'; | ||
import { createRenderer } from 'test/utils'; | ||
import { expect } from 'chai'; | ||
import { useInput } from '@mui/base/InputUnstyled'; | ||
|
||
describe('useInput', () => { | ||
const { render } = createRenderer(); | ||
describe('params: inputRef', () => { | ||
it('should be able to attach input ref passed through params', () => { | ||
const inputRef = React.createRef<HTMLInputElement>(); | ||
|
||
function Input() { | ||
const { getInputProps } = useInput({ | ||
inputRef, | ||
}); | ||
return <input {...getInputProps()} />; | ||
} | ||
const { getByRole } = render(<Input />); | ||
|
||
expect(inputRef.current).to.deep.equal(getByRole('textbox')); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters