[TextField] Implemented masking#3783
Conversation
| return outputMask; | ||
| } | ||
|
|
||
| private _extractValueFromMask(maskedValue: string, element: HTMLInputElement | HTMLTextAreaElement): string { |
There was a problem hiding this comment.
I don't think you use element any where in this method
| // Check for backspace | ||
| if (key == 8) { | ||
| if (this.props.mask && this.state.maskCursorPosition && this.state.value) { | ||
| if ((event.target as HTMLInputElement).selectionStart >= this.state.maskCursorPosition) { |
There was a problem hiding this comment.
I can select multiple characters and still satisfy this condition, but the value will only be set as 1 less than my current value length.
There was a problem hiding this comment.
If you select multiple characters and backspace them, the inputChanged event will detect that you deleted a bunch of characters. Like if you ctrl+a and backspace, it will clear any input the user has made and display the empty mask.
| valueIndex < maskedValue.length && | ||
| maskedValue.charAt(valueIndex) != mask.charAt(maskIndex)) { | ||
| skippedChars++; | ||
| valueIndex++; |
There was a problem hiding this comment.
Won't it be possible for the valueIndex be 1 higher than you expect since it will increment once this while loop exits? At least if you have text that's something like a_a_a
…into magellan/textFieldMasking
| import * as React from 'react'; | ||
| /* tslint:enable:no-unused-variable */ | ||
| import { TextField } from 'office-ui-fabric-react/lib/TextField'; | ||
| import { DefaultTextField } from 'office-ui-fabric-react/lib/TextField'; |
There was a problem hiding this comment.
Why do you change all of the examples to use DefaultTextField instead of TextField? That doesn't seem right
There was a problem hiding this comment.
For the same reason all of the Button examples were changed to use DefaultButton instead of Button.
There was a problem hiding this comment.
What about compat, when I use TextField today, will I have to change to DefaultTextfield with this change?
There was a problem hiding this comment.
No, just as with button, the TextField component still exists, it will just warn you for using a deprecated component.
There was a problem hiding this comment.
@lambertwang I don't really think that's a good idea.
…into magellan/textFieldMasking
| <tr> | ||
| <td> | ||
| <TextField | ||
| <DefaultTextField |
There was a problem hiding this comment.
Why are you renaming everything that was TextField to DefaultTextField? That feels counterintuitive.
|
Any updates on this @lambertwang? |
| inputProperties, | ||
| textAreaProperties | ||
| } from '../../Utilities'; | ||
| import { AnimationClassNames } from '../../Styling'; |
| /> | ||
| <MaskedTextField | ||
| label='With input mask' | ||
| mask='Phone Number: (999) 999 - 9999' |
There was a problem hiding this comment.
I don't understand how this example works. I will try to get a demo from you.
dzearing
left a comment
There was a problem hiding this comment.
This is a little confusing, can you demo for me?
…c-react into magellan/textFieldMasking # Conflicts: # packages/office-ui-fabric-react/src/components/ContextualMenu/examples/ContextualMenu.Directional.Example.tsx
…t into magellan/textFieldMasking
…fice-ui-fabric-react into magellan/textFieldMasking
| @@ -0,0 +1,325 @@ | |||
| import * as React from 'react'; | |||
There was a problem hiding this comment.
This is missing tests. Needs a bunch of enzyme tests. And probably a snapshot test or two.
| "changes": [ | ||
| { | ||
| "packageName": "office-ui-fabric-react", | ||
| "comment": "TextField: Inmplemented input masking.", |
|
@dzearing @cschleiden Can I get another review? I've made some changes and added enzyme tests for the component. |
…into magellan/textFieldMasking
cliffkoh
left a comment
There was a problem hiding this comment.
As Travis CI indicated, your change has a lot of null check failures. Please update your submission to resolve the issues.. I will take a look at your unit tests though.
|
@lambertwang FTFY: lambertwang-zz#1 |
…king Fix build break issues with your PR
cliffkoh
left a comment
There was a problem hiding this comment.
@lambertwang You now have a bunch of unused vars errors due to the recent change to tslint :)
The tests look fine. I did not look very closely at other changes besides the test since other reviewers have looked at it so approving for now.
…into magellan/textFieldMasking
* master: DetailsRow: Flexshrink fix (microsoft#4622) [TextField] Implemented masking (microsoft#3783) Applying package updates. ComboBox: Add any event as additional parameter to onChanged callback for saving pending changes (microsoft#4594) Remove usage of Number.NaN (microsoft#4615)
Pull request checklist
$ npm run changeDescription of changes
Implemented input masking (similar to https://www.npmjs.com/package/react-input-mask)
Note: the MaskedTextField is its own component. The original TextField component should be untouched.