Skip to content
This repository has been archived by the owner on Oct 6, 2020. It is now read-only.

feat(Form): Add <PhoneInput /> and <DateInput />; Clean up <Select /> #34

Merged
merged 16 commits into from
Apr 1, 2019

Conversation

kylealwyn
Copy link
Contributor

@kylealwyn kylealwyn commented Mar 22, 2019

  • Adds new <PhoneInput /> and <DateInput /> components for easy input masking
  • Fixes some existing styling issues with <Select />

@codecov-io
Copy link

codecov-io commented Mar 22, 2019

Codecov Report

Merging #34 into master will decrease coverage by 21.19%.
The diff coverage is 82.22%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #34      +/-   ##
==========================================
- Coverage   88.88%   67.69%   -21.2%     
==========================================
  Files          13       21       +8     
  Lines         198      421     +223     
  Branches       31       88      +57     
==========================================
+ Hits          176      285     +109     
- Misses         15      106      +91     
- Partials        7       30      +23
Impacted Files Coverage Δ
src/utils.js 94.59% <100%> (+1.04%) ⬆️
src/Form/Input.js 46.55% <100%> (ø)
src/Form/EasyInput.js 66.66% <66.66%> (ø)
src/Form/PhoneInput.js 75% <75%> (ø)
src/Form/DateInput.js 87.5% <87.5%> (ø)
src/Form/Label.js 33.33% <0%> (ø)
src/Form/FormError.js 50% <0%> (ø)
src/Form/Field.js 100% <0%> (ø)
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b6b0d9b...c606806. Read the comment docs.

@kylealwyn kylealwyn changed the title feat(Form): Form and Date Inputs feat(Form): Add <FormInput /> and <DateInput />; Clean up <Select /> Mar 23, 2019
@kylealwyn kylealwyn requested a review from a team March 25, 2019 22:53
@choochootrain choochootrain changed the title feat(Form): Add <FormInput /> and <DateInput />; Clean up <Select /> feat(Form): Add <PhoneInput /> and <DateInput />; Clean up <Select /> Mar 25, 2019
@kylealwyn kylealwyn marked this pull request as ready for review March 27, 2019 17:51
@kylealwyn
Copy link
Contributor Author

@heydoctor/engineering

@erikshestopal
Copy link
Contributor

erikshestopal commented Mar 27, 2019

EDIT: removing node_modules and rerunning npm did the trick.
Running yarn docs crashes with the following trace:

Uncaught TypeError: Cannot set property 'jsx' of undefined
    at module.exports (webpack-internal:///./node_modules/acorn-jsx/inject.js:362)
    at eval (webpack-internal:///./node_modules/acorn-jsx/index.js:3)
    at Object../node_modules/acorn-jsx/index.js (:1235/static/js/vendors.js:227)
    at __webpack_require__ (:1235/static/js/runtime~app.js:801)
    at fn (:1235/static/js/runtime~app.js:164)
    at eval (webpack-internal:///./node_modules/buble/dist/buble-browser.es.js:9)
    at Module../node_modules/buble/dist/buble-browser.es.js (:1235/static/js/vendors.js:532)
    at __webpack_require__ (:1235/static/js/runtime~app.js:801)
    at fn (:1235/static/js/runtime~app.js:164)
    at eval (webpack-internal:///./node_modules/react-live/dist/react-live.es.js:26)
    at Module../node_modules/react-live/dist/react-live.es.js (:1235/static/js/vendors.js:10903)
    at __webpack_require__ (:1235/static/js/runtime~app.js:801)
    at fn (:1235/static/js/runtime~app.js:164)
    at eval (webpack-internal:///./node_modules/docz-theme-default/dist/index.m.js:48)
    at Module../node_modules/docz-theme-default/dist/index.m.js (:1235/static/js/vendors.js:5128)
    at __webpack_require__ (:1235/static/js/runtime~app.js:801)
    at fn (:1235/static/js/runtime~app.js:164)
    at Module.eval (webpack-internal:///./.docz/app/root.jsx:6)
    at eval (webpack-internal:///./.docz/app/root.jsx:59)
    at Module../.docz/app/root.jsx (:1235/static/js/app.js:34)
    at __webpack_require__ (:1235/static/js/runtime~app.js:801)
    at fn (:1235/static/js/runtime~app.js:164)
    at Module.eval (webpack-internal:///./.docz/app/index.jsx:6)
    at eval (webpack-internal:///./.docz/app/index.jsx:70)
    at Module../.docz/app/index.jsx (:1235/static/js/app.js:22)
    at __webpack_require__ (:1235/static/js/runtime~app.js:801)
    at fn (:1235/static/js/runtime~app.js:164)
    at Object.0 (:1235/static/js/app.js:791)
    at __webpack_require__ (:1235/static/js/runtime~app.js:801)
    at checkDeferredModules (:1235/static/js/runtime~app.js:60)
    at Array.webpackJsonpCallback [as push] (:1235/static/js/runtime~app.js:47)
    at :1235/static/js/app.js:1

@erikshestopal
Copy link
Contributor

@kylealwyn Played around with the inputs to try and break them. Let me know if these are valid bugs:

Trying to delete a backslash makes the cursor jump to the end:

date


Trying to delete a parenthesis makes the cursor jump to the end:

phone

}
};

return <Input forwardedRef={ref} value={currentValue} onChange={handleChange} {...inputProps} />;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Should we set a maxLength of 10 numbers (or 11 with country code)?
  2. Can we make this input type="tel" by default so we can have a numpad on mobile devices?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we specify the expected format as a parenthetical aspect in the label (e.g. (123) 123-1234). Should we also allow the character required for the format? For example, if a user types in "(" they are currently blocked from doing so, which might be unintuitive if the format is specified in the label. Or maybe not. Perhaps we could consider masking (https://www.uxbooth.com/articles/the-new-rules-of-form-design/, https://uxplanet.org/designing-perfect-text-field-clarity-accessibility-and-user-effort-d03c1e26004b).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That behavior is dictated by Google's libphonenumber to disallow the leading paren so I'd rather not get in the way. It's also more difficult to type a paren on mobile when the numpad is presented.

@kylealwyn
Copy link
Contributor Author

@erikshestopal Country code support is in

Copy link
Contributor

@cehsu cehsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are really slick. I agree with Erik's comments.

<option value="">{placeholder || 'Select an option...'}</option>
<SelectContainer value={value} size={size}>
<SelectInput name={name} value={value} onChange={this.handleChange} onBlur={this.handleBlur}>
<SelectOption value="">{placeholder || 'Select an option...'}</SelectOption>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These guidelines advise against using an option to replace a label (which is not exactly what is happening here): https://designsystem.digital.gov/components/form-controls/

Instead, we could add any additional guidance as a parenthetical portion of the label: States (please select a state), as it seems like the label is typically used to convey instructions to users.

Additional examples:
https://www.w3.org/TR/wai-aria-practices-1.1/examples/listbox/listbox-collapsible.html
https://webaim.org/techniques/forms/controls
http://www.webaxe.org/accessible-custom-select-dropdowns/

src/Form/Select.js Outdated Show resolved Hide resolved
src/Form/Input.js Show resolved Hide resolved
src/Form/DateInput.js Show resolved Hide resolved
src/Form/DateInput.js Outdated Show resolved Hide resolved
}
};

return <Input forwardedRef={ref} value={currentValue} onChange={handleChange} {...inputProps} />;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we specify the expected format as a parenthetical aspect in the label (e.g. (123) 123-1234). Should we also allow the character required for the format? For example, if a user types in "(" they are currently blocked from doing so, which might be unintuitive if the format is specified in the label. Or maybe not. Perhaps we could consider masking (https://www.uxbooth.com/articles/the-new-rules-of-form-design/, https://uxplanet.org/designing-perfect-text-field-clarity-accessibility-and-user-effort-d03c1e26004b).

@kylealwyn kylealwyn force-pushed the feat/phone-date-inputs branch from 5d1636f to c794767 Compare March 29, 2019 20:06
@kylealwyn kylealwyn merged commit 801047a into master Apr 1, 2019
@kylealwyn kylealwyn deleted the feat/phone-date-inputs branch April 1, 2019 18:24
kylealwyn added a commit that referenced this pull request Apr 5, 2019
…p to DateInput (#36)

## Fix
I forgot to include theses exports in #34 😞Seems like something a robot should disallow 

## Add
Also adds support to DateInput for an `initialValue` prop. This solves an issue where the database stores ISO dates (YYYY-MM-DD) but we want to display MM/DD/YYYY on the client. We can't format the `value` prop, otherwise we'll incorrectly format incomplete dates on every render.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants