Skip to content

Comments

Refactor DateSeparator using MVVM and move to shared-components#32482

Open
rbondesson wants to merge 20 commits intoelement-hq:developfrom
ZacksBot:refactor/date-separator
Open

Refactor DateSeparator using MVVM and move to shared-components#32482
rbondesson wants to merge 20 commits intoelement-hq:developfrom
ZacksBot:refactor/date-separator

Conversation

@rbondesson
Copy link
Contributor

@rbondesson rbondesson commented Feb 12, 2026

Checklist

Refactor and move DateSeparator to shared-components

Summary

  • Moved DateSeparator component to @element-hq/web-shared-components package as DateSeparatorView

Changes

New shared component

  • Adopted the ViewModel pattern (MVVM) for the component, introducing the DateSeparatorViewSnapshot interface
  • Added CSS module for styling, Storybook for visual testing and unit tests with snapshot coverage

Codebase migration

  • Added DateSeparatorViewModel.tsx to element-web including unit-test

Codebase migration

  • Components in element-web now renders DateSeparatorView instead of the old component.

Test plan

  • Verify date separator renders correctly in rooms
  • Check Storybook stories render correctly and create new screenshots
  • Run new unit tests in shared component
  • Run unit tests for affected components in element-web
  • Run visual tests for affected components in element-web

Tests

Before & After

  • Before Refactoring
image image
  • After Refactoring
image image

@github-actions github-actions bot added the Z-Community-PR Issue is solved by a community member's PR label Feb 12, 2026
@rbondesson rbondesson added the T-Task Tasks for the team like planning label Feb 12, 2026
this.updateSnapshot();
};

private renderJumpToDateMenu(label: string): React.ReactElement {
Copy link
Member

Choose a reason for hiding this comment

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

Rendering out the UI is part of the view's job so this code should be moved to DateSeparatorView.
You could add a property to the snapshot, say jumpToDateEnabled and then have the view render out two different sub-views based on that snapshot value:

if(jumpToDateEnabled) {
    return <SimpleDateSeparatorView vm={vm} />;
}
else {
    return <JumpDateSeparatorView vm={vm} />;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The components rendered in jumpToDateMenu are currently not present in shared components.
ContextMenuTooltipButton, IconizedContextMenu, IconizedContextMenuOptionList, IconizedContextMenuOption add JumpToDatePicker. The JumpToDatePicker component is on the list of components to migrate, but the others are not.

I could create a new component for jumpToDateMenu, but it will be an element-web component, or I can leave as is. Which way do you prefer?

…here manual handling is preferrable over wrapper component.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-Task Tasks for the team like planning Z-Community-PR Issue is solved by a community member's PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants