-
Notifications
You must be signed in to change notification settings - Fork 1
MPDX-9818 - Add DA5 and A33 warnings/errors to goal settings #1930
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
Open
zweatshirt
wants to merge
4
commits into
main
Choose a base branch
from
MPDX-9818
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
acbb3af
Return the account list ID from useNewStaffGoalCalculation
zweatshirt 9390f6d
Add over cap flags to the goal calculation query
zweatshirt 624415c
Show admin warnings in Goal Settings
zweatshirt bb84087
Outline the fields behind a warning
zweatshirt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,8 @@ | ||
| import { TextFieldProps } from '@mui/material'; | ||
| import { useField } from 'formik'; | ||
| import { NewStaffGoalCalculationAttributesInput } from 'src/graphql/types.generated'; | ||
| import { useGoalSettingsPreview } from '../GoalSettingsPreviewContext'; | ||
| import { WarningSeverity } from '../goalSettingsWarnings'; | ||
|
|
||
| export type GoalSettingsFieldBaseProps = Omit<TextFieldProps, 'name'> & { | ||
| /** Formik field key. Required here even though MUI's `name` is optional. */ | ||
|
|
@@ -17,6 +19,19 @@ export type GoalSettingsFieldBaseProps = Omit<TextFieldProps, 'name'> & { | |
| showLabel?: boolean; | ||
| }; | ||
|
|
||
| const outlineSx = (severity: WarningSeverity) => ({ | ||
|
Contributor
Author
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.
[Suggestion] The contributing-field outline is **color-only**. For salary/debt the warning text names the concept, but fields like `geographicLocation` and `contribution403bPercentage` (in `SALARY_CAP_FIELDS`) get no textual/icon/ARIA pointer — the tinted border is their sole cue. `aria-invalid` is correctly avoided (these are advisory, not validation errors), so this is an acceptable tradeoff, but a known a11y residual worth a follow-up if those fields need a non-color indicator.
|
||
| '.MuiOutlinedInput-notchedOutline': { | ||
| borderColor: `${severity}.main`, | ||
| }, | ||
| // Needs the ampersand: :hover applies to the root, not a descendant. | ||
| '&:hover .MuiOutlinedInput-notchedOutline': { | ||
| borderColor: `${severity}.dark`, | ||
| }, | ||
| '.Mui-focused .MuiOutlinedInput-notchedOutline': { | ||
| borderColor: `${severity}.main`, | ||
| }, | ||
| }); | ||
|
|
||
| /** | ||
| * Shared wiring for every Goal Settings field: Formik binding, consistent MUI | ||
| * chrome defaults, and accessible-name construction. Returns merged | ||
|
|
@@ -38,6 +53,7 @@ export const useGoalSettingsField = ({ | |
| ...props | ||
| }: GoalSettingsFieldBaseProps): TextFieldProps => { | ||
| const [field, meta] = useField(name); | ||
| const preview = useGoalSettingsPreview(); | ||
|
|
||
| const accessibleName = | ||
| typeof label === 'string' | ||
|
|
@@ -47,6 +63,8 @@ export const useGoalSettingsField = ({ | |
| : undefined; | ||
|
|
||
| const showError = Boolean(meta.touched && meta.error); | ||
| // A validation error is actionable, so it wins over the advisory outline. | ||
| const severity = showError ? undefined : preview?.fieldSeverity(name); | ||
|
|
||
| return { | ||
| id: name, | ||
|
|
@@ -58,6 +76,10 @@ export const useGoalSettingsField = ({ | |
| ...field, | ||
| error: showError, | ||
| helperText: showError ? meta.error : undefined, | ||
| sx: { | ||
| ...(severity ? outlineSx(severity) : {}), | ||
| ...props.sx, | ||
| }, | ||
| inputProps: { | ||
| ...(!showLabel && accessibleName ? { 'aria-label': accessibleName } : {}), | ||
| ...inputProps, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.