Repository navigation
Gate report field list selection behind a Save button (a11y On Input, PR 16) #101687
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
Changes from all commits
09dac50
ff34cb7
e5fdb99
d076696
621f675
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 |
|---|---|---|
|
|
@@ -12,7 +12,7 @@ import {getReportFieldOptionsSection} from '@libs/ReportFieldOptionsListUtils'; | |
|
|
||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
|
|
||
| import React from 'react'; | ||
| import React, {useState} from 'react'; | ||
|
|
||
| type EditReportFieldDropdownPageProps = { | ||
| /** Value of the policy report field */ | ||
|
|
@@ -62,18 +62,21 @@ function EditReportFieldDropdown({ | |
|
|
||
| const validFieldOptions = fieldOptions?.filter((option) => !!option)?.sort(localeCompare); | ||
|
|
||
| const [draftValue, setDraftValue] = useState<string>(); | ||
| const currentValue = draftValue ?? fieldValue; | ||
|
|
||
| // Freeze the value selected when the picker opened so it drives the pinned "Selected" section for the whole open/focus cycle. | ||
| // The live value still drives the checkmark, so tapping a row marks it without reordering the list. The reorder happens only on reopen. | ||
| const initialFieldValue = useInitialSelection(fieldValue, {resetOnFocus: true}); | ||
|
|
||
| const optionSections = getReportFieldOptionsSection({ | ||
| searchValue: debouncedSearchValue, | ||
| // Live value drives the checkmark, so tapping a row marks it immediately. | ||
| // Staged value drives the checkmark, so tapping a row marks it immediately. | ||
| selectedOptions: [ | ||
| { | ||
| keyForList: fieldValue, | ||
| searchText: fieldValue, | ||
| text: fieldValue, | ||
| keyForList: currentValue, | ||
| searchText: currentValue, | ||
| text: currentValue, | ||
| }, | ||
| ], | ||
| // Frozen value drives the pinned section, so the list doesn't reorder while selecting. | ||
|
|
@@ -109,10 +112,13 @@ function EditReportFieldDropdown({ | |
| titleNumberOfLines={shouldUseCompactRows ? 2 : undefined} | ||
| shouldShowTextInput={shouldShowTextInput} | ||
| textInputOptions={textInputOptions} | ||
| // Re-selecting the value the field already holds submits that same value rather than an empty string. | ||
| // Both call sites compare the submitted value against the stored one and skip the save themselves, so | ||
| // signalling "no change" this way is no longer needed and leaves '' free to mean "cleared". | ||
| onSelectRow={(option) => onSubmit({[fieldKey]: option?.text ?? ''})} | ||
| onSelectRow={(option) => setDraftValue(option?.text ?? '')} | ||
|
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.
When the user taps the currently checked option—or selects a new option and taps it again—this always stages Useful? React with 👍 / 👎.
Contributor
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. @MelvinBot Check this comment
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. I don't think we should change this. On This PR only moves the save behind a Save button for WCAG 3.2.2. It shouldn't bring back toggle-to-clear. Tapping the selected row now picks the same value, so Save stays disabled. The test in If you want toggle-to-clear back, let me know and I'll add it. 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.
The existing cases in Useful? React with 👍 / 👎.
Contributor
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. @MelvinBot Check this comment
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. Already handled in e5fdb99. The
That commit also fixed |
||
| confirmButtonOptions={{ | ||
|
Contributor
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. This is also the list in the inline report field dropdown from #104124 (ReportFieldInlineInput), so the change hits that dropdown too. Picking a value there stops saving, and the Save button goes into a popover sized with |
||
| showButton: true, | ||
| text: translate('common.save'), | ||
| onConfirm: () => onSubmit({[fieldKey]: currentValue}), | ||
| isDisabled: draftValue === undefined || draftValue === fieldValue, | ||
| }} | ||
| initiallyFocusedItemKey={initialFieldValue} | ||
| shouldUpdateFocusedIndex | ||
| /> | ||
|
|
||
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.
NAB: the comment above still says the live value drives the checkmark, it's the staged value now. Can we update it so the two agree?