fix(notification): replace view-all anchor with button to prevent iframe navigation #552
@@ -14,7 +14,7 @@ type Props = {
|
||||
let { notifications, onMarkRead, onMarkAllRead, onClose }: Props = $props();
|
||||
|
||||
function handleViewAll() {
|
||||
onClose();
|
||||
onClose(); // close first — avoids stale dropdown during navigation transition
|
||||
goto('/aktivitaeten');
|
||||
}
|
||||
</script>
|
||||
@@ -135,8 +135,9 @@ function handleViewAll() {
|
||||
<div class="border-t border-line px-4 py-2">
|
||||
<button
|
||||
type="button"
|
||||
role="link"
|
||||
onclick={handleViewAll}
|
||||
class="text-xs font-medium text-ink-2 transition-colors hover:text-ink"
|
||||
class="min-h-[44px] px-1 text-xs font-medium text-ink-2 transition-colors hover:text-ink"
|
||||
>
|
||||
{m.chronik_view_all()}
|
||||
</button>
|
||||
|
||||
@@ -159,7 +159,7 @@ describe('NotificationDropdown', () => {
|
||||
expect(onMarkAllRead).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
it('calls onClose when the view-all button is clicked', async () => {
|
||||
it('calls onClose when the view-all link is clicked', async () => {
|
||||
const onClose = vi.fn();
|
||||
render(NotificationDropdown, {
|
||||
props: {
|
||||
@@ -170,12 +170,12 @@ describe('NotificationDropdown', () => {
|
||||
}
|
||||
});
|
||||
|
||||
await page.getByRole('button', { name: /alle aktivitäten|view all/i }).click();
|
||||
await page.getByRole('link', { name: /alle aktivitäten|view all/i }).click();
|
||||
|
||||
expect(onClose).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
it('navigates to /aktivitaeten when the view-all button is clicked', async () => {
|
||||
it('navigates to /aktivitaeten when the view-all link is clicked', async () => {
|
||||
render(NotificationDropdown, {
|
||||
props: {
|
||||
notifications: [],
|
||||
@@ -185,11 +185,29 @@ describe('NotificationDropdown', () => {
|
||||
}
|
||||
});
|
||||
|
||||
await page.getByRole('button', { name: /alle aktivitäten|view all/i }).click();
|
||||
await page.getByRole('link', { name: /alle aktivitäten|view all/i }).click();
|
||||
|
||||
expect(goto).toHaveBeenCalledWith('/aktivitaeten');
|
||||
});
|
||||
|
||||
it('calls onClose before navigating to /aktivitaeten', async () => {
|
||||
const callOrder: string[] = [];
|
||||
const onClose = vi.fn(() => callOrder.push('close'));
|
||||
(goto as ReturnType<typeof vi.fn>).mockImplementation(() => callOrder.push('goto'));
|
||||
render(NotificationDropdown, {
|
||||
props: {
|
||||
notifications: [],
|
||||
onMarkRead: () => {},
|
||||
onMarkAllRead: () => {},
|
||||
onClose
|
||||
}
|
||||
});
|
||||
|
||||
await page.getByRole('link', { name: /alle aktivitäten|view all/i }).click();
|
||||
|
||||
expect(callOrder).toEqual(['close', 'goto']);
|
||||
});
|
||||
|
||||
it('renders MENTION items with the mention verb text', async () => {
|
||||
render(NotificationDropdown, {
|
||||
props: {
|
||||
|
||||
Reference in New Issue
Block a user