Skip to content

[scheduler] Highlight only the edited occurrence of a recurring event#22873

Merged
rita-codes merged 7 commits into
mui:masterfrom
Anexus5919:fix/scheduler-recurring-edit-highlight
Jun 23, 2026
Merged

[scheduler] Highlight only the edited occurrence of a recurring event#22873
rita-codes merged 7 commits into
mui:masterfrom
Anexus5919:fix/scheduler-recurring-edit-highlight

Conversation

@Anexus5919

Copy link
Copy Markdown
Contributor

Closes #22839

Summary

When an event's edit dialog is open, its chip gets the data-editing "editing" surface color. For a recurring event, opening the dialog on a single occurrence highlighted every occurrence of the series across the grid instead of only the one that was clicked.

Root cause

The "editing" highlight was keyed by the event id. All occurrences of a recurring event share the same base id, so the equality check in the isEditedEvent selector matched every occurrence at once. Each occurrence already carries a unique, stable occurrence.key (${eventId}::${dateKey} for recurring occurrences, String(eventId) for single events), which is what should identify the active occurrence.

Changes

The edit highlight is now keyed on the occurrence key instead of the event id, consistently across every consumer:

  • Store: editedEventId state and setEditedEventId are now editedOccurrenceKey / setEditedOccurrenceKey (typed string | null).
  • Selector: isEditedEvent is now isEditedOccurrence and compares occurrence keys.
  • useEvent takes an occurrenceKey parameter; useDraggableEvent passes the occurrenceKey it already receives.
  • EventItem and the EventDialog open/close handlers now use occurrence.key.

This keeps single (non-recurring) events working unchanged, since their occurrence key equals their stringified id, while distinguishing the individual occurrences of a recurring series.

Testing

  • Added a selector test proving two occurrences of the same recurring event (same base id, different keys) are distinguished.
  • Added a DOM regression test in the premium timeline: with a daily recurring event expanded into several occurrences, opening one occurrence highlights exactly one chip.
  • Updated the existing selector, store snapshot, and dialog state tests for the rename.
  • pnpm --filter "@mui/x-scheduler" run typescript, pnpm eslint, and pnpm test:unit --project "x-scheduler*" --run all pass (1633 unit tests).

Steps to reproduce

Recurring events are expanded into multiple occurrences only when the premium recurring plugin is attached, so use a premium component:

  1. Render EventCalendarPremium (or EventTimelinePremium) with a daily recurring event over a multi-day view.
  2. Click one occurrence to open its edit dialog.
  3. Before: every occurrence is highlighted. After: only the clicked occurrence is highlighted, and it clears when the dialog closes.

Changelog

Fixed an issue in the Scheduler where editing one occurrence of a recurring event highlighted all of its occurrences instead of only the edited one.

  • I have followed (at least) the PR section of the contributing guide.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@Anexus5919

Copy link
Copy Markdown
Contributor Author

@rita-codes Could you please review this PR when you have a chance? Thanks!

@code-infra-dashboard

code-infra-dashboard Bot commented Jun 17, 2026

Copy link
Copy Markdown

Deploy preview

https://deploy-preview-22873--material-ui-x.netlify.app/

Bundle size

Bundle Parsed size Gzip size
@mui/x-data-grid 0B(0.00%) 0B(0.00%)
@mui/x-data-grid-pro 0B(0.00%) 0B(0.00%)
@mui/x-data-grid-premium 0B(0.00%) 0B(0.00%)
@mui/x-charts 0B(0.00%) 0B(0.00%)
@mui/x-charts-pro 0B(0.00%) 0B(0.00%)
@mui/x-charts-premium 0B(0.00%) 0B(0.00%)
@mui/x-date-pickers 0B(0.00%) 0B(0.00%)
@mui/x-date-pickers-pro 0B(0.00%) 0B(0.00%)
@mui/x-tree-view 0B(0.00%) 0B(0.00%)
@mui/x-tree-view-pro 0B(0.00%) 0B(0.00%)
@mui/x-license 0B(0.00%) 0B(0.00%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

@Anexus5919

Copy link
Copy Markdown
Contributor Author

@rita-codes
Oh I forgot to include the before-and-after state of the fix. Here it is:

Before

React.Scheduler.component.-.MUI.X.-.Google.Chrome.2026-06-18.02-46-02.mp4

After

React.Scheduler.component.-.MUI.X.-.Google.Chrome.2026-06-18.02-55-56.mp4

@rita-codes rita-codes added type: bug It doesn't behave as expected. scope: scheduler Changes related to the scheduler. labels Jun 19, 2026

@rita-codes rita-codes left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice fix 👏 Keying the highlight on occurrence.key instead of the shared base id is the right call, and the rename is consistent across all the real consumers/

Two minor, non-blocking notes:

  1. EventTimelinePremium.test.tsx — the regression test asserts exactly one chip has data-editing, but not that it's the one that was clicked. With a single match it's almost certainly correct, but asserting the identity would guard against a future "highlights the wrong occurrence" bug.
  2. EventDialog.test.tsx — the renamed "should expose the active occurrence key on the store" test is a more honest name than the old one, but neither version actually exercises the clear-on-close path (onClosesetEditedOccurrenceKey(null)). That's a pre-existing gap, not something this PR introduces, just flagging it since the close handler is part of this surface.

Neither is a blocker for this PR, though.

Thank you so much for taking care of this! 🙇‍♀️ 🥇

@Anexus5919

Copy link
Copy Markdown
Contributor Author

Thank you so much, @rita-codes! 🙏 I really appreciate the thoughtful review, both suggestions made the tests meaningfully stronger. I have addressed them in the follow-up commit.

Thanks again for catching these, and for the kind words. 🙌

@rita-codes
rita-codes merged commit ce68956 into mui:master Jun 23, 2026
21 checks passed
mbrookes pushed a commit to mbrookes/mui-x that referenced this pull request Jun 27, 2026
…mui#22873)

Co-authored-by: Rita <[email protected]>
Co-authored-by: Rita Iglesias Gandara <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: scheduler Changes related to the scheduler. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[scheduler] Editing one occurrence of a recurring event highlights all occurrences

2 participants