LG-8330: Allow user to select USPS location when search box is empty#7760
LG-8330: Allow user to select USPS location when search box is empty#7760eileen-nava merged 5 commits intomainfrom
Conversation
…ys and activeErrors is empty
…ocation when search box is empty
| onChange={onTextInputChange} | ||
| label={t('in_person_proofing.body.location.po_search.address_search_label')} | ||
| hint={t('in_person_proofing.body.location.po_search.address_search_hint')} | ||
| disabled={disabled} |
There was a problem hiding this comment.
Interesting... how does this fix the issue? Does the FormSteps stuff ignore disabled fields even after invalidation?
There was a problem hiding this comment.
@NavaTim I'm just curious — how does this work/fix the bug?
There was a problem hiding this comment.
@allthesignals: I think this answers what you're asking, but please say so if I missed your q. @eileen-nava filled me in on the inner workings here. The form steps component is just a standard form element, so when you pass an attribute of 'disabled' to that form field, it does not validate that field. TIL: MDN Disabled Overview
There was a problem hiding this comment.
Oh, great! I assumed FormSteps was doing validation... sounds like it's being done natively!
There was a problem hiding this comment.
@allthesignals The ValidatedFieldElement hooks into the invalid event, which doesn't trigger when the element is disabled.
Relevant spec sections:
valid = element.checkValidity()
Returns true if the element's value has no validity problems; false otherwise. Fires aninvalidevent at the element in the latter case.
Note that the invalid event in the above source is mentioned as being triggered by the constraint validation API.
Constraint validation: If an element is disabled, it is barred from constraint validation.
A submittable element is a candidate for constraint validation except when a condition has barred the element from constraint validation. (For example, an element is barred from constraint validation if it is an object element.)
There was a problem hiding this comment.
Fascinating. Thank you Tim!
NavaTim
left a comment
There was a problem hiding this comment.
Overall PR looks good and like what we discussed, but would be good to add a test here to prevent regression.
Good point, I added a test. |
| await userEvent.clear( | ||
| await findByLabelText('in_person_proofing.body.location.po_search.address_search_label'), | ||
| ); |
There was a problem hiding this comment.
Probably would move this and related prereq steps to the beforeEach, but it's not very important at the moment because we only have one it in this context.
🎫 Ticket
8330: User cannot select an IPP location if search box is empty
🛠 Summary of changes
📜 Testing Plan
Happy Path
Edge Cases
Run through the happy path, but then....
Run through the happy path, but then....
👀 Screenshots
If relevant, include a screenshot or screen capture of the changes.
Feature In Action:
SelectLocationWithEmptySearchBox.mov