Skip to content

Conversation

@Mazen-Saeed
Copy link

This PR fixes the inconsistency between Calendar and Table views when trying to edit createdAt date field.

Previously, calendar cards could be dragged even though the createdAt field are UI read-only, resulting in the confusing and inconsistent behavior compared to the Table view where the field is not editable.

The issue was caused by the drag logic checking only user permissions and not the field’s UI read-only metadata. This change updates the calendar drag logic to also check for isUIReadOnly, ensuring that records are not draggable when the selected calendar date field is read-only.

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.

No issues found across 1 file

@github-actions
Copy link
Contributor

Welcome!

Hello there, congrats on your first PR! We're excited to have you contributing to this project.
By submitting your Pull Request, you acknowledge that you agree with the terms of our Contributor License Agreement.

Generated by 🚫 dangerJS against 3856eec

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 22, 2026

Greptile Summary

Fixed calendar view drag behavior to respect UI read-only field metadata, ensuring consistency with table view behavior.

  • Added isUIReadOnly check to isCalendarFieldReadOnly calculation
  • Calendar cards with read-only date fields (like createdAt) can no longer be dragged
  • Combined both UI read-only metadata and permission-based checks using OR logic
  • Aligns calendar drag behavior with existing table view implementation pattern

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The change is a simple, focused fix that adds a missing check for UI read-only field metadata. The logic follows the established pattern seen in isRecordFieldReadOnly utility and correctly uses the OR operator to combine the two read-only conditions. The fix addresses a legitimate bug where calendar cards could be dragged even when the field was marked as UI read-only.
  • No files require special attention

Important Files Changed

Filename Overview
packages/twenty-front/src/modules/object-record/record-calendar/record-calendar-card/components/RecordCalendarCardDraggableContainer.tsx Added isUIReadOnly check to prevent dragging calendar cards when the field is UI read-only, fixing inconsistency with table view behavior

Sequence Diagram

sequenceDiagram
    participant User
    participant RecordCalendarCardDraggableContainer
    participant useRecordCalendarContext
    participant useIsRecordReadOnly
    participant useObjectPermissionsForObject
    participant Recoil as Recoil State
    participant isFieldMetadataReadOnlyByPermissions
    participant Draggable

    User->>RecordCalendarCardDraggableContainer: Attempts to drag calendar card
    RecordCalendarCardDraggableContainer->>useRecordCalendarContext: Get objectMetadataItem
    useRecordCalendarContext-->>RecordCalendarCardDraggableContainer: Return objectMetadataItem
    
    RecordCalendarCardDraggableContainer->>useIsRecordReadOnly: Check if record is read-only
    useIsRecordReadOnly-->>RecordCalendarCardDraggableContainer: Return isRecordReadOnly
    
    RecordCalendarCardDraggableContainer->>useObjectPermissionsForObject: Get object permissions
    useObjectPermissionsForObject-->>RecordCalendarCardDraggableContainer: Return objectPermissions
    
    RecordCalendarCardDraggableContainer->>Recoil: Get recordIndexCalendarFieldMetadataId
    Recoil-->>RecordCalendarCardDraggableContainer: Return calendar field metadata ID
    
    RecordCalendarCardDraggableContainer->>RecordCalendarCardDraggableContainer: Find calendarFieldMetadataItem by ID
    
    alt calendarFieldMetadataItem exists
        RecordCalendarCardDraggableContainer->>RecordCalendarCardDraggableContainer: Check isUIReadOnly
        RecordCalendarCardDraggableContainer->>isFieldMetadataReadOnlyByPermissions: Check permissions
        isFieldMetadataReadOnlyByPermissions-->>RecordCalendarCardDraggableContainer: Return permission-based read-only status
        RecordCalendarCardDraggableContainer->>RecordCalendarCardDraggableContainer: Combine isUIReadOnly OR permission-based read-only
    else calendarFieldMetadataItem is null
        RecordCalendarCardDraggableContainer->>RecordCalendarCardDraggableContainer: Set isCalendarFieldReadOnly = false
    end
    
    RecordCalendarCardDraggableContainer->>RecordCalendarCardDraggableContainer: Calculate isDragDisabled = isRecordReadOnly OR isCalendarFieldReadOnly
    RecordCalendarCardDraggableContainer->>Draggable: Pass isDragDisabled prop
    
    alt isDragDisabled is true
        Draggable-->>User: Dragging prevented (cursor shows not-allowed)
    else isDragDisabled is false
        Draggable-->>User: Dragging allowed
    end
Loading

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 22, 2026

Greptile found no issues!

From now on, if a review finishes and we haven't found any issues, we will not post anything, but you can confirm that we reviewed your changes in the status check section.

This feature can be toggled off in your Code Review Settings by deselecting "Create a status check for each PR".

@github-actions
Copy link
Contributor

🚀 Preview Environment Ready!

Your preview environment is available at: http://bore.pub:61464

This environment will automatically shut down when the PR is closed or after 5 hours.

@lucasbordeau lucasbordeau self-requested a review January 22, 2026 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant