Skip to content

Commit

Permalink
[docs] Fix masked text field bug (#20397)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattcorner authored Apr 3, 2020
1 parent 7bb8c2c commit 7c37586
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 4 additions & 2 deletions docs/src/pages/components/text-fields/FormattedInputs.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function NumberFormatCustom(props) {
onValueChange={(values) => {
onChange({
target: {
name: props.name,
value: values.value,
},
});
Expand All @@ -59,6 +60,7 @@ function NumberFormatCustom(props) {

NumberFormatCustom.propTypes = {
inputRef: PropTypes.func.isRequired,
name: PropTypes.string.isRequired,
onChange: PropTypes.func.isRequired,
};

Expand All @@ -83,7 +85,7 @@ export default function FormattedInputs() {
<Input
value={values.textmask}
onChange={handleChange}
name="formatted-text-mask-input"
name="textmask"
id="formatted-text-mask-input"
inputComponent={TextMaskCustom}
/>
Expand All @@ -92,7 +94,7 @@ export default function FormattedInputs() {
label="react-number-format"
value={values.numberformat}
onChange={handleChange}
name="formatted-numberformat-input"
name="numberformat"
id="formatted-numberformat-input"
InputProps={{
inputComponent: NumberFormatCustom,
Expand Down
8 changes: 5 additions & 3 deletions docs/src/pages/components/text-fields/FormattedInputs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ function TextMaskCustom(props: TextMaskCustomProps) {

interface NumberFormatCustomProps {
inputRef: (instance: NumberFormat | null) => void;
onChange: (event: { target: { value: string } }) => void;
onChange: (event: { target: { name: string; value: string } }) => void;
name: string;
}

function NumberFormatCustom(props: NumberFormatCustomProps) {
Expand All @@ -52,6 +53,7 @@ function NumberFormatCustom(props: NumberFormatCustomProps) {
onValueChange={(values) => {
onChange({
target: {
name: props.name,
value: values.value,
},
});
Expand Down Expand Up @@ -89,7 +91,7 @@ export default function FormattedInputs() {
<Input
value={values.textmask}
onChange={handleChange}
name="formatted-text-mask-input"
name="textmask"
id="formatted-text-mask-input"
inputComponent={TextMaskCustom as any}
/>
Expand All @@ -98,7 +100,7 @@ export default function FormattedInputs() {
label="react-number-format"
value={values.numberformat}
onChange={handleChange}
name="formatted-numberformat-input"
name="numberformat"
id="formatted-numberformat-input"
InputProps={{
inputComponent: NumberFormatCustom as any,
Expand Down

0 comments on commit 7c37586

Please sign in to comment.