Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Initial portions of support for Field validation #2780

Merged
merged 11 commits into from
Mar 14, 2019

Conversation

jryans
Copy link
Collaborator

@jryans jryans commented Mar 12, 2019

Reviewer: Most commits in this PR are fairly self-contained, so you may want to review commit by commit, since there are quite a few changes here.

This extends @ara4n's previously reviewed (but unmerged) validation prototype from #2550. (The first commit is that same work rebased, and so it could be ignored / reviewed more lightly.)

This adds a basic facility for showing validation with Fields. However, the UX of the validation itself has still needs to be tweaked and improved. It is also not applied to any Fields in this work. You can see an example of the API from the prototype code.

I am putting this code up for review now since there are already a lot of changes here, so it seems best to review this chunk and then iterate from there.

2019-03-12 at 18 02

Part of element-hq/element-web#8170 and element-hq/element-web#8292.

ara4n and others added 11 commits March 12, 2019 14:02
 * renames RoomTooltip to be a generic Tooltip (which it is)
 * hooks it into Field to show validation results
 * adds onValidate to Field to let Field instances call an arbitrary validation function

Rebased from @ara4n's matrix-org#2550
by @jryans. Subsequent commits revise and adapt this work.
* The field border style was previously moved up to the field
* Validity colors should be shown regardless of focus state
This checks `onValidate` in `render` to make the linter happy.
Always set some value on the Field's input so that it doesn't flip flop between
controlled and uncontrolled.
As part of adding validation to Field, the logic is simpler to follow if we can
assume that all usages of Field use it as a controlled component, instead of
supporting both controlled and uncontrolled.

This converts the uncontrolled usages to controlled.
Field is no longer used as an uncontrolled component, so we can remove some
supporting code that we no longer need.
This is example code from @ara4n's work in
matrix-org#2550. We're not ready to
actually apply validation yet, so removing this for now.
@jryans jryans requested a review from a team March 13, 2019 09:33
Copy link
Member

@turt2live turt2live left a comment

Choose a reason for hiding this comment

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

I'm trusting and assuming 40f16fa is okay - I Haven't bothered to look

Overall the changes look sensible though, and well laid out. It's a bit of a shame to lose uncontrolled inputs, but I can see how annoying it is to deal with :(

@jryans jryans merged commit 45063ca into matrix-org:develop Mar 14, 2019
jryans added a commit to jryans/matrix-react-sdk that referenced this pull request Mar 14, 2019
This aligns the code in `RegistrationForm` with other users of the `Field`
component. (In matrix-org#2780, I had
thought that this code would be okay to leave alone, but I had missed the usage
of the `Field` value getter.)

Fixes element-hq/element-web#9172
dbkr added a commit that referenced this pull request Mar 15, 2019
#2780 renamed
RoomTooltip (to Tooltip) but missed the references in the custom
tag panel.
@dbkr dbkr mentioned this pull request Mar 15, 2019
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.

3 participants