Skip to content

Commit

Permalink
fix: saved search input didnt get correct initial value (#1764)
Browse files Browse the repository at this point in the history
  • Loading branch information
seanes authored Jan 31, 2025
1 parent 36feefe commit b7a02ea
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion packages/bff/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@azure/keyvault-keys": "^4.7.2",
"@azure/monitor-opentelemetry": "1.7.0",
"@digdir/dialogporten-node-logger": "workspace:*",
"@digdir/dialogporten-schema": "1.47.4-4b9bad0",
"@digdir/dialogporten-schema": "1.47.5-431c529",
"@fastify/cookie": "^9.3.1",
"@fastify/cors": "^9.0.1",
"@fastify/formbody": "^7.4.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"i18n:sort": "tsx ./src/i18n/check.ts --sort"
},
"dependencies": {
"@altinn/altinn-components": "^0.14.2",
"@altinn/altinn-components": "^0.15.3",
"@digdir/designsystemet-css": "0.11.0-next.10",
"@digdir/designsystemet-react": "1.0.0-next.15",
"@digdir/designsystemet-theme": "1.0.0-next.14",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ export const getAlertBadgeProps = (count: number): BadgeProps | undefined => {
if (count > 0) {
return {
label: count.toString(),
size: 'xs',
theme: 'base',
color: 'alert',
};
}
};
Expand Down Expand Up @@ -89,11 +92,9 @@ export const useGlobalMenu = ({
id: '1',
groupId: 'global',
size: 'lg',
icon: 'inbox',
theme: 'base',
iconVariant: 'solid',
icon: { name: 'inbox', theme: 'base', variant: 'solid' },
title: t('sidebar.inbox'),
alertBadge: getAlertBadgeProps(needsAttentionPerView.inbox),
iconBadge: getAlertBadgeProps(needsAttentionPerView.inbox),
badge: getBadgeProps(itemsPerViewCount.inbox, dialogCountsInconclusive),
selected: pathname === PageRoutes.inbox,
expanded: true,
Expand Down
27 changes: 13 additions & 14 deletions packages/frontend/src/pages/SavedSearches/SavedSearchesPage.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { type BookmarksListItemProps, BookmarksSection } from '@altinn/altinn-components';
import { BookmarksSection } from '@altinn/altinn-components';
import { useSnackbar } from '@altinn/altinn-components';
import type { EditableBookmarkProps } from '@altinn/altinn-components/dist/types/lib/components';
import { useQueryClient } from '@tanstack/react-query';
import { useState } from 'react';
import { type ChangeEvent, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Link } from 'react-router-dom';
import { deleteSavedSearch, updateSavedSearch } from '../../api/queries.ts';
Expand Down Expand Up @@ -34,13 +35,13 @@ export const SavedSearchesPage = () => {

if (isLoadingSavedSearches) {
const skeletonItems = 3;
const items: BookmarksListItemProps[] = Array.from({ length: savedSearches?.length || skeletonItems }, (_, i) => ({
const items = Array.from({ length: skeletonItems }, (_, i) => ({
id: i.toString(),
title: t('savedSearches.loading_saved_searches') + randomString(),
}));
return (
<div className={styles.savedSearchesWrapper}>
<BookmarksSection title={t('savedSearches.loading_saved_searches')} items={items} loading={true} />
<BookmarksSection title={t('savedSearches.loading_saved_searches')} items={items} loading />
</div>
);
}
Expand Down Expand Up @@ -82,7 +83,7 @@ export const SavedSearchesPage = () => {
queryParams.append(filter.id, String(filter.value));
}

const itemObject: BookmarksListItemProps = {
const itemObject: EditableBookmarkProps = {
id: savedSearch.id.toString(),
params: [],
title: '',
Expand All @@ -100,8 +101,7 @@ export const SavedSearchesPage = () => {
void queryClient.invalidateQueries({ queryKey: [QUERY_KEYS.SAVED_SEARCHES] });
setExpandedId('');
})
.catch((e) => {
console.error('Failed to update saved search:', e);
.catch(() => {
openSnackbar({
message: t('savedSearches.update_failed'),
color: 'alert',
Expand All @@ -122,16 +122,15 @@ export const SavedSearchesPage = () => {
void queryClient.invalidateQueries({ queryKey: [QUERY_KEYS.SAVED_SEARCHES] });
setExpandedId('');
})
.catch((e) => {
console.error('Failed to delete saved search:', e);
.catch(() => {
openSnackbar({
message: t('savedSearches.delete_failed'),
color: 'alert',
});
});
},
},
onChange: (e) => {
onChange: (e: ChangeEvent<HTMLInputElement>) => {
setSavedSearchInputValue(e.target.value);
},
inputValue: savedSearchInputValue,
Expand All @@ -155,11 +154,11 @@ export const SavedSearchesPage = () => {
});

const handleOnToggle = (itemId: string) => {
if (expandedId === itemId) {
setExpandedId('');
return;
const nextExpandedId = itemId === expandedId ? '' : itemId;
if (nextExpandedId) {
setSavedSearchInputValue(items?.find((item) => item.id === nextExpandedId)?.title ?? '');
}
setExpandedId(itemId);
setExpandedId(nextExpandedId);
};

return (
Expand Down
28 changes: 14 additions & 14 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b7a02ea

Please sign in to comment.