Skip to content
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: System message shows undefined when selecting an already selected list value #55118

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions src/pages/EditReportFieldDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,14 @@ type EditReportFieldDropdownPageComponentProps = {
/** Key of the policy report field */
fieldKey: string;

/** ID of the policy this report field belongs to */
// eslint-disable-next-line react/no-unused-prop-types
policyID: string;

/** Options of the policy report field */
fieldOptions: string[];

/** Callback to fire when the Save button is pressed */
onSubmit: (form: Record<string, string>) => void;
};

type EditReportFieldDropdownPageProps = EditReportFieldDropdownPageComponentProps;

function EditReportFieldDropdownPage({onSubmit, fieldKey, fieldValue, fieldOptions}: EditReportFieldDropdownPageProps) {
function EditReportFieldDropdownPage({onSubmit, fieldKey, fieldValue, fieldOptions}: EditReportFieldDropdownPageComponentProps) {
const [recentlyUsedReportFields] = useOnyx(ONYXKEYS.RECENTLY_USED_REPORT_FIELDS);
const [searchValue, debouncedSearchValue, setSearchValue] = useDebouncedState('');
const theme = useTheme();
Expand Down
5 changes: 3 additions & 2 deletions src/pages/EditReportFieldPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ function EditReportFieldPage({route}: EditReportFieldPageProps) {
ReportActions.updateReportName(report.reportID, value, report.reportName ?? '');
goBack();
} else {
ReportActions.updateReportField(report.reportID, {...reportField, value: value === '' ? null : value}, reportField);
if (value !== '') {
ReportActions.updateReportField(report.reportID, {...reportField, value}, reportField);
}
Navigation.dismissModal(isSearchTopmostCentralPane() ? undefined : report?.reportID);
}
};
Expand Down Expand Up @@ -139,7 +141,6 @@ function EditReportFieldPage({route}: EditReportFieldPageProps) {

{reportField.type === 'dropdown' && (
<EditReportFieldDropdown
policyID={report.policyID ?? '-1'}
fieldKey={fieldKey}
fieldValue={fieldValue}
fieldOptions={policyField.values.filter((_value: string, index: number) => !policyField.disabledOptions.at(index))}
Expand Down
Loading