mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
parent
4a3ce66193
commit
5f61266931
@ -15,6 +15,16 @@ jest.mock('../../utils/measureText', () => {
|
||||
});
|
||||
|
||||
describe('AutoSizeInput', () => {
|
||||
it('should support default Input API', () => {
|
||||
const onChange = jest.fn();
|
||||
render(<AutoSizeInput onChange={onChange} value="" />);
|
||||
|
||||
const input: HTMLInputElement = screen.getByTestId('autosize-input');
|
||||
fireEvent.change(input, { target: { value: 'foo' } });
|
||||
|
||||
expect(onChange).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should have default minWidth when empty', () => {
|
||||
render(<AutoSizeInput />);
|
||||
|
||||
|
@ -20,6 +20,7 @@ export const AutoSizeInput = React.forwardRef<HTMLInputElement, Props>((props, r
|
||||
minWidth = 10,
|
||||
maxWidth,
|
||||
onCommitChange,
|
||||
onChange,
|
||||
onKeyDown,
|
||||
onBlur,
|
||||
value: controlledValue,
|
||||
@ -48,6 +49,9 @@ export const AutoSizeInput = React.forwardRef<HTMLInputElement, Props>((props, r
|
||||
ref={ref}
|
||||
value={value.toString()}
|
||||
onChange={(event) => {
|
||||
if (onChange) {
|
||||
onChange(event);
|
||||
}
|
||||
setValue(event.currentTarget.value);
|
||||
}}
|
||||
width={inputWidth}
|
||||
|
Loading…
Reference in New Issue
Block a user