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: selected departments not being displayed due to pagination #30365

Merged
merged 1 commit into from
Sep 12, 2023
Merged
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
5 changes: 5 additions & 0 deletions .changeset/slimy-cheetahs-heal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Fixed selected departments not being displayed due to pagination
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ type DepartmentListItem = {
_id: string;
label: string;
value: string;
_updatedAt: Date;
};

export const useDepartmentsList = (
Expand Down Expand Up @@ -66,7 +65,6 @@ export const useDepartmentsList = (
_id,
label: department.archived ? `${name} [${t('Archived')}]` : name,
value: _id,
_updatedAt: new Date(_updatedAt || ''),
};
});

Expand All @@ -75,15 +73,13 @@ export const useDepartmentsList = (
_id: '',
label: t('All'),
value: 'all',
_updatedAt: new Date(),
});

options.haveNone &&
items.unshift({
_id: '',
label: t('None'),
value: '',
_updatedAt: new Date(),
});

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const EditDepartmentWithData = ({ id, title }: EditDepartmentWithDataProps) => {
});

if (isInitialLoading) {
return <FormSkeleton />;
return <FormSkeleton padding='1.5rem 1rem' maxWidth='37.5rem' margin='0 auto' />;
}

if (isError || (id && !data?.department)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ export const DepartmentForwarding = ({ departmentId, value = [], handler, label

const { phase: departmentsPhase, items: departmentsItems, itemCount: departmentsTotal } = useRecordList(departmentsList);

const options = useMemo(() => {
const pending = value.filter(({ value }) => !departmentsItems.find((dep) => dep.value === value));
return [...departmentsItems, ...pending];
}, [departmentsItems, value]);

return (
<Field>
<Field.Label>{t(label)}</Field.Label>
Expand All @@ -41,7 +46,7 @@ export const DepartmentForwarding = ({ departmentId, value = [], handler, label
filter={debouncedDepartmentsFilter}
setFilter={setDepartmentsFilter}
onChange={handler}
options={departmentsItems}
options={options}
value={value}
placeholder={t('Select_an_option')}
endReached={
Expand Down