-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(a11y): always enable continue button on FindProperty select page #3143
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,9 +51,13 @@ function Component(props: Props) { | |
: "os-address"; | ||
const [page, setPage] = useState<"os-address" | "new-address">(startPage); | ||
|
||
const [showPostcodeError, setShowPostcodeError] = useState<boolean>(false); | ||
const [addressAutocompleteError, setAddressAutocompleteError] = | ||
useState<string>(); | ||
const [mapValidationError, setMapValidationError] = useState<string>(); | ||
const [showSiteDescriptionError, setShowSiteDescriptionError] = | ||
useState<boolean>(false); | ||
const [dataFetchError, setDataFetchError] = useState<string>(); | ||
|
||
const [address, setAddress] = useState<SiteAddress | undefined>( | ||
previouslySubmittedData?._address, | ||
|
@@ -111,7 +115,16 @@ function Component(props: Props) { | |
}, [data, address]); | ||
|
||
const validateAndSubmit = () => { | ||
// TODO `if (isValidating)` on either page, wrap Continue button in error mesage? | ||
if (isValidating) { | ||
setDataFetchError("Please wait for data fetching to complete"); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After the user has selected an address on either page, we need to make a quick request to Planning Data to fetch supplmental data about it that we can't get from Ordnance Survey - and we want to prevent the user from "continuing" before this fetch completes. We used to simply set A couple questions here:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Open questions from dev call:
|
||
|
||
if (page === "os-address") { | ||
if (address?.postcode === undefined) setShowPostcodeError(true); | ||
|
||
if (address?.title === undefined) | ||
setAddressAutocompleteError("Select an address"); | ||
} | ||
|
||
if (page === "new-address") { | ||
if (address?.x === undefined && address?.y === undefined) | ||
|
@@ -155,11 +168,8 @@ function Component(props: Props) { | |
return ( | ||
<Card | ||
handleSubmit={validateAndSubmit} | ||
isValid={ | ||
page === "new-address" && !isValidating | ||
? true | ||
: Boolean(address) && !isValidating | ||
} | ||
isValid={true} | ||
error={dataFetchError} | ||
> | ||
{getBody()} | ||
</Card> | ||
|
@@ -190,7 +200,7 @@ function Component(props: Props) { | |
/> | ||
{Boolean(address) && isValidating && ( | ||
<DelayedLoadingIndicator | ||
msDelayBeforeVisible={50} | ||
msDelayBeforeVisible={0} | ||
text="Fetching data..." | ||
/> | ||
)} | ||
|
@@ -216,6 +226,10 @@ function Component(props: Props) { | |
} | ||
id={props.id} | ||
description={props.description || ""} | ||
showPostcodeError={showPostcodeError} | ||
setShowPostcodeError={setShowPostcodeError} | ||
addressAutocompleteError={addressAutocompleteError} | ||
setAddressAutocompleteError={setAddressAutocompleteError} | ||
/> | ||
{!props.allowNewAddresses ? ( | ||
<ExternalPlanningSiteDialog | ||
|
@@ -238,7 +252,7 @@ function Component(props: Props) { | |
)} | ||
{Boolean(address) && isValidating && ( | ||
<DelayedLoadingIndicator | ||
msDelayBeforeVisible={50} | ||
msDelayBeforeVisible={0} | ||
text="Fetching data..." | ||
/> | ||
)} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrapping the web component in our error wrapper isn't perfect because it means the error message & select label will be out of normal order, with the error message above the label rather than below. I suspect the underlying markup may be a bit imperfect and disconnected too - but haven't inspected closely yet.
I see a couple possible ways forward:
error
prop here?)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notes from dev call: