Skip to content

Fix: date range selector#6625

Merged
sriramveeraghanta merged 5 commits intopreviewfrom
fix-dat-range-selector
Feb 19, 2025
Merged

Fix: date range selector#6625
sriramveeraghanta merged 5 commits intopreviewfrom
fix-dat-range-selector

Conversation

@gakshita
Copy link
Collaborator

@gakshita gakshita commented Feb 18, 2025

Description

This PR removes the action buttons from date range. And selects them on date click itself.

Summary by CodeRabbit

  • New Features
    • Introduced a new Calendar component for improved date selection.
  • Refactor
    • Streamlined the date range selector by removing confirmation and cancel buttons.
    • Date selections are now applied immediately, simplifying the interaction flow.
  • Bug Fixes
    • Updated date selection logic to enhance usability and consistency across components.
  • Chores
    • Downgraded the react-day-picker dependency version to ensure compatibility.

@gakshita gakshita marked this pull request as draft February 18, 2025 06:41
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 18, 2025

Walkthrough

The DateRangeDropdown component has been updated by simplifying its date selection logic. The conditional check for the "both dates required" scenario has been removed, resulting in a direct call to the onSelect function whenever a date is chosen. Additionally, the component's footer—with buttons for canceling or applying a date selection—has been removed. Despite these UI changes, state management for the selected date range and dropdown behavior remains unchanged. A new Calendar component has been introduced, replacing the DayPicker component across various files.

Changes

File Summary
web/core/components/dropdowns/date-range.tsx Removed conditional check for bothRequired in the date selection logic; eliminated the footer containing cancel/apply buttons, simplifying the user interaction.
packages/ui/src/calendar.tsx Introduced a new Calendar component utilizing DayPicker, with customizable props and simplified styling.
packages/ui/src/index.ts Added export statement for the new Calendar component.
web/core/components/core/filters/date-filter-modal.tsx Replaced DayPicker with Calendar, updated classNames, and maintained existing functionality for date selection.
web/core/components/dropdowns/date.tsx Replaced DayPicker with Calendar, simplified classNames handling, and updated focus management prop.
web/core/components/inbox/modals/snooze-issue-modal.tsx Replaced DayPicker with Calendar, removed unused variables, and updated classNames.
web/package.json Downgraded react-day-picker dependency from ^9.5.0 to 8.10.1.

Possibly related PRs

Suggested labels

🌐frontend, 🐛bug, 🌟improvement

Suggested reviewers

  • SatishGandham
  • prateekshourya29

Poem

I'm a hopping bunny on a code spree,
Simplifying logic with much glee.
No more buttons weighing down the flow,
Just smooth date picks, watch it go!
Bugs and clutter, now set free.
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@gakshita gakshita changed the title Fix dat range selector Fix: date range selector Feb 18, 2025
@gakshita gakshita self-assigned this Feb 18, 2025
@gakshita gakshita marked this pull request as ready for review February 18, 2025 11:14
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🔭 Outside diff range comments (1)
web/core/components/inbox/modals/snooze-issue-modal.tsx (1)

69-69: ⚠️ Potential issue

Fix undefined close function call.

The close() function is called but not defined. Use handleClose instead, which is provided in props.

-                      close();
+                      handleClose();
🧹 Nitpick comments (1)
web/core/components/dropdowns/date.tsx (1)

62-101: Consider extracting dropdown logic to a custom hook.

The dropdown handling logic (state, refs, popper setup, keyboard interactions) could be extracted into a reusable custom hook to improve maintainability and reusability.

Example structure:

// hooks/use-date-dropdown.ts
export const useDateDropdown = ({ onClose, onChange, closeOnSelect }) => {
  const [isOpen, setIsOpen] = useState(false);
  const dropdownRef = useRef<HTMLDivElement | null>(null);
  const [referenceElement, setReferenceElement] = useState<HTMLButtonElement | null>(null);
  const [popperElement, setPopperElement] = useState<HTMLDivElement | null>(null);
  
  // ... popper setup, keyboard handlers, etc.
  
  return {
    isOpen,
    dropdownRef,
    referenceElement,
    popperElement,
    setReferenceElement,
    setPopperElement,
    handleClose,
    handleKeyDown,
    handleOnClick,
    styles,
    attributes,
  };
};
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e74b10e and 71afd9c.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (7)
  • packages/ui/src/calendar.tsx (1 hunks)
  • packages/ui/src/index.ts (1 hunks)
  • web/core/components/core/filters/date-filter-modal.tsx (3 hunks)
  • web/core/components/dropdowns/date-range.tsx (2 hunks)
  • web/core/components/dropdowns/date.tsx (2 hunks)
  • web/core/components/inbox/modals/snooze-issue-modal.tsx (2 hunks)
  • web/package.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/core/components/dropdowns/date-range.tsx
🔇 Additional comments (8)
packages/ui/src/index.ts (1)

33-33: LGTM! Export added in the correct location.

The new calendar module export follows the existing pattern and maintains alphabetical order.

packages/ui/src/calendar.tsx (2)

30-34: Verify color contrast ratios for accessibility.

The background colors used for selected dates (bg-custom-primary-100) should be verified for sufficient contrast with the text colors to ensure WCAG compliance.

#!/usr/bin/env python3
import requests
from colorsys import rgb_to_hls

def get_contrast_ratio(color1, color2):
    # Convert hex to RGB
    r1, g1, b1 = int(color1[1:3], 16), int(color1[3:5], 16), int(color1[5:7], 16)
    r2, g2, b2 = int(color2[1:3], 16), int(color2[3:5], 16), int(color2[5:7], 16)
    
    # Calculate relative luminance
    def get_luminance(r, g, b):
        rs = r/255
        gs = g/255
        bs = b/255
        if rs <= 0.03928: r = rs/12.92
        else: r = ((rs+0.055)/1.055) ** 2.4
        if gs <= 0.03928: g = gs/12.92
        else: g = ((gs+0.055)/1.055) ** 2.4
        if bs <= 0.03928: b = bs/12.92
        else: b = ((bs+0.055)/1.055) ** 2.4
        return 0.2126 * r + 0.7152 * g + 0.0722 * b

    l1 = get_luminance(r1, g1, b1)
    l2 = get_luminance(r2, g2, b2)
    
    # Calculate contrast ratio
    if l1 > l2:
        return (l1 + 0.05) / (l2 + 0.05)
    return (l2 + 0.05) / (l1 + 0.05)

# Get your theme colors and verify contrast
# Note: Replace these with your actual theme colors
bg_color = "#F3F4F6"  # custom-primary-100
text_color = "#FFFFFF" # white

ratio = get_contrast_ratio(bg_color, text_color)
print(f"Contrast ratio: {ratio:.2f}")
print(f"WCAG AA compliance (minimum 4.5:1): {'Pass' if ratio >= 4.5 else 'Fail'}")

1-58: Well-structured Calendar component with comprehensive styling!

The implementation:

  • Properly extends DayPicker with custom styling
  • Includes responsive design considerations
  • Handles outside days and disabled states
  • Uses custom navigation icons
  • Exports with correct TypeScript types
web/core/components/inbox/modals/snooze-issue-modal.tsx (1)

50-65: Clean Calendar integration with proper date constraints!

The Calendar implementation:

  • Correctly handles date selection
  • Properly disables past dates
  • Maintains the existing modal functionality
web/core/components/dropdowns/date.tsx (1)

176-189: Clean Calendar integration with proper configuration!

The Calendar implementation:

  • Correctly handles date selection
  • Properly manages focus with initialFocus
  • Maintains existing date constraints
  • Shows outside days for better context
web/core/components/core/filters/date-filter-modal.tsx (2)

8-8: LGTM! Calendar component integration looks good.

The replacement of DayPicker with the new Calendar component from @plane/ui is well-implemented. The component configurations maintain the necessary functionality for date selection and validation.

Also applies to: 96-110, 121-135


148-161: Verify if action buttons should be removed.

The PR objectives mention removing action buttons for date selection, but this component still includes Cancel/Apply buttons. Please verify if these buttons should also be removed as part of the date range selector modifications.

web/package.json (1)

59-59:

Details

❓ Verification inconclusive

Verify the rationale for downgrading react-day-picker.

The package version has been downgraded from ^9.5.0 to 8.10.1. This is a major version downgrade that could introduce breaking changes.

Let's check the changelog and compatibility:

Additionally, run this script to check for potential version conflicts:


🏁 Script executed:

#!/bin/bash
# Check for react-day-picker usage and potential version conflicts
npm ls react-day-picker

# Check for any peer dependency warnings
npm ls 2>&1 | grep "UNMET PEER DEPENDENCY"

Length of output: 93


🌐 Web query:

What are the breaking changes between react-day-picker v8 and v9?

💡 Result:

React DayPicker v9 introduces several breaking changes from v8 that developers need to address during upgrades:

1. Dependency Changes

  • date-fns moved from peer dependencies to direct dependencies[4][7]
  • Removed Moment.js support entirely (already deprecated in v8)[5]

2. Component Architecture

  • Complete overhaul of component structure with renamed core components:
    v8 Component v9 Equivalent
    Caption MonthCaption
    HeadRow Weekdays
    Row Week
    Day DayButton

3. Prop Changes

  • Removed deprecated props:
    • useInput hook completely removed (migration guide required)[4][7]
    • onWeekNumberClick discontinued[4]
    • onDayTouchStart/onDayDoubleClick eliminated[4]
  • New required props for accessibility:
    <DayPicker 
      labels={{ 
        headRow: 'Week numbers',
        navNext: 'Next month' 
      }}
    />

4. Styling Breakage

  • Simplified CSS with updated class names (.rdp-head.rdp-weekdays)[4][9]
  • Font family inheritance changed (system-ui → parent element's font)[2][4]

5. Localization Changes

  • Persian calendar replaces Jalali calendar implementation[2][4]
  • ISO week calculation now uses locale settings by default[1][4]

6. Behavior Changes

  • Month navigation buttons repositioned to top-right[5][9]
  • Strict type checking enforced for TypeScript users[4][7]

7. Modifier System

  • Requires dual configuration for custom modifiers:
    dayPickerProps={{
      modifiers: { weekend: { dayOfWeek: [0,6] } },
      modifiersClassNames: { weekend: 'weekend-style' }
    }}
    ```[5][8]

Key upgrade steps include updating CSS imports (dist/style.css), replacing deprecated components[9], and migrating from DateUtils to date-fns functions[1]. The maintainers provide an Upgrading Guide with code transformation examples[9].

Citations:


Action Needed: Confirm Impact of React-Day-Picker Version Downgrade

The dependency in the file web/package.json has been downgraded from ^9.5.0 to a strictly pinned 8.10.1. As the web changelog indicates, there are significant breaking changes between v8 and v9 (e.g., altered component structure, prop removals, and styling adjustments). Although the automated checks (via the npm ls commands) did not report any peer dependency conflicts, the absence of output means we should manually verify the following:

  • Rationale Confirmation: Ensure that the downgrade was intentional to accommodate compatibility with the new Calendar component or related usage.
  • Breaking Changes Verification: Confirm that none of the breaking changes introduced in v9 (such as renamed components or removed props) are inadvertently expected by other parts of the application.
  • Manual Checks: Since the shell script produced an empty result, please double-check locally whether any instances in the codebase rely on v9-specific features.

Please review and validate these aspects to ensure that the version downgrade does not introduce unforeseen issues.

@sriramveeraghanta sriramveeraghanta merged commit f9d154d into preview Feb 19, 2025
5 of 6 checks passed
@sriramveeraghanta sriramveeraghanta deleted the fix-dat-range-selector branch February 19, 2025 09:31
@coderabbitai coderabbitai bot mentioned this pull request Mar 3, 2025
@coderabbitai coderabbitai bot mentioned this pull request Mar 19, 2025
1 task
lifeiscontent pushed a commit that referenced this pull request Aug 18, 2025
* fix: Handled workspace switcher closing on click

* fix: removed action btns from date range selector

* fix: updated calendar component
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🌟enhancement New feature or request 🎨UI / UX

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants