Skip to content

feat: persist filters across booking tabs #21705

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

Closed

Conversation

livebitz1
Copy link

@livebitz1 livebitz1 commented Jun 4, 2025

What does this PR do?

This PR implements filter persistence across booking tabs to improve user experience. When users switch between different booking tabs (upcoming, unconfirmed, recurring, past, cancelled), their filter preferences are now maintained.

Visual Demo

Before:

  • Filters reset when switching between booking tabs
  • User needs to reapply filters in each tab

After:

  • Filters persist across all booking tabs
  • User's filter preferences are maintained when switching tabs
  • Filters persist even after page refresh

Mandatory Tasks

  • I have self-reviewed the code
  • N/A - No documentation changes required
  • Added tests for filter persistence functionality

How should this be tested?

  1. Set up:

    • No special environment variables needed
    • Access to bookings page with multiple tabs
  2. Test Steps:

    • Go to /bookings/upcoming
    • Apply some filters (e.g., date range, event type)
    • Switch to another tab (e.g., /bookings/past)
    • Verify filters persist
    • Refresh the page
    • Verify filters still persist
  3. Expected Behavior:

    • Filters should maintain their state across tab switches
    • Filters should persist after page refresh
    • Filter state should be isolated per user

Checklist

  • I have read the contributing guide
  • My code follows the style guidelines
  • I have commented my code where necessary
  • My changes generate no new warnings

Summary by cubic

Filters now stay applied when switching between booking tabs and after refreshing the page, making it easier to manage bookings.

  • New Features
    • Filter settings are saved and restored across all booking tabs.
    • Filters persist after a page reload.

@graphite-app graphite-app bot added the community Created by Linear-GitHub Sync label Jun 4, 2025
@graphite-app graphite-app bot requested a review from a team June 4, 2025 11:19
Copy link

vercel bot commented Jun 4, 2025

Someone is attempting to deploy a commit to the cal Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions bot added consumer enterprise area: enterprise, audit log, organisation, SAML, SSO 🧹 Improvements Improvements to existing features. Mostly UX/UI labels Jun 4, 2025
Copy link

graphite-app bot commented Jun 4, 2025

Graphite Automations

"Add consumer team as reviewer" took an action on this PR • (06/04/25)

1 reviewer was added to this PR based on Keith Williams's automation.

"Add community label" took an action on this PR • (06/04/25)

1 label was added to this PR based on Keith Williams's automation.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Himanshu Meena seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@dosubot dosubot bot added bookings area: bookings, availability, timezones, double booking ✨ feature New feature or request labels Jun 4, 2025
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cubic found 4 issues across 3 files. Review them in cubic.dev

React with 👍 or 👎 to teach cubic. Tag @cubic-dev-ai to give specific feedback.

@@ -0,0 +1,68 @@
import { useCallback, useEffect, useState } from "react";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This hook calls the client-only Next.js hook usePathname, but the file lacks a 'use client' directive at the top. Without it, the module is treated as a server module and using usePathname will cause a build error in Next.js 13+.

}

export function useSharedFilters(tableIdentifier: string) {
const pathname = usePathname();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pathname variable is declared but never used, resulting in an unused variable that will trigger ESLint warnings and increases code noise.

Suggested change
const pathname = usePathname();
// const pathname = usePathname(); // removed – variable was unused

pageSize,
searchTerm,
});
}, [activeFilters, sorting, columnVisibility, columnSizing, pageSize, searchTerm]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setFilters is used inside the effect but not included in the dependency array, breaking the exhaustive-deps rule and risking updates being written with a stale function reference.

Suggested change
}, [activeFilters, sorting, columnVisibility, columnSizing, pageSize, searchTerm]);
}, [activeFilters, sorting, columnVisibility, columnSizing, pageSize, searchTerm, setFilters]);

if (sharedFilters.columnSizing) setColumnSizing(sharedFilters.columnSizing);
if (sharedFilters.pageSize) setPageSize(sharedFilters.pageSize);
if (sharedFilters.searchTerm) setSearchTerm(sharedFilters.searchTerm);
}, [tableIdentifier]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getFilters is referenced inside this effect but omitted from the dependency array, which violates the exhaustive-deps rule and can lead to stale data being loaded if sharedFilters changes after mount.

Suggested change
}, [tableIdentifier]);
}, [tableIdentifier, getFilters]);

@anikdhabal
Copy link
Contributor

@livebitz1 Thanks for your work! But I prefer the other ones—they’re shorter and simpler

@anikdhabal anikdhabal closed this Jun 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bookings area: bookings, availability, timezones, double booking community Created by Linear-GitHub Sync consumer enterprise area: enterprise, audit log, organisation, SAML, SSO ✨ feature New feature or request 🧹 Improvements Improvements to existing features. Mostly UX/UI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Persist filters across tabs to improve user experience
3 participants