Skip to content

Commit

Permalink
fix(FormControl): onChange and innerRef ts decls (#3583,#3568,#2781) (#…
Browse files Browse the repository at this point in the history
…4435)

- Added tests to simple.test.tsx
  • Loading branch information
craigpg authored and jquense committed Oct 18, 2019
1 parent 5051ef6 commit 74a36bc
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
9 changes: 7 additions & 2 deletions types/components/FormControl.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@ import * as React from 'react';
import Feedback from './Feedback';
import { BsPrefixComponent } from './helpers';

type FormControlElement =
| HTMLInputElement
| HTMLSelectElement
| HTMLTextAreaElement;

export interface FormControlProps {
innerRef?: React.LegacyRef<this>;
innerRef?: React.LegacyRef<FormControlElement>;
size?: 'sm' | 'lg';
plaintext?: boolean;
readOnly?: boolean;
disabled?: boolean;
value?: string;
onChange?: React.FormEventHandler<this>;
onChange?: React.FormEventHandler<FormControlElement>;
type?: string;
id?: string;
isValid?: boolean;
Expand Down
26 changes: 23 additions & 3 deletions types/simple.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,24 @@ import {
<Form>
<Form.Group controlId="exampleForm.ControlInput1">
<Form.Label>Email address</Form.Label>
<Form.Control type="email" placeholder="name@example.com" />
<Form.Control
type="email"
placeholder="name@example.com"
innerRef={React.createRef<HTMLInputElement>()}
onChange={(e: React.FormEvent<HTMLInputElement>) => {
e;
}}
/>
</Form.Group>
<Form.Group controlId="exampleForm.ControlSelect1">
<Form.Label>Example select</Form.Label>
<Form.Control as="select">
<Form.Control
as="select"
innerRef={React.createRef<HTMLSelectElement>()}
onChange={(e: React.FormEvent<HTMLSelectElement>) => {
e;
}}
>
<option>1</option>
<option>2</option>
<option>3</option>
Expand All @@ -192,7 +205,14 @@ import {
</Form.Group>
<Form.Group controlId="exampleForm.ControlTextarea1">
<Form.Label>Example textarea</Form.Label>
<Form.Control as="textarea" rows={3} />
<Form.Control
as="textarea"
rows={3}
innerRef={React.createRef<HTMLTextAreaElement>()}
onChange={(e: React.FormEvent<HTMLTextAreaElement>) => {
e;
}}
/>
</Form.Group>
<Form.Group as={Row} controlId="exampleForm.HorizontalControl">
<Form.Label column sm={2}>
Expand Down

0 comments on commit 74a36bc

Please sign in to comment.