Skip to content
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

[DateRangePicker] Fix calendar day outside of month layout shifting on hover #6448

Merged
merged 3 commits into from Oct 12, 2022

Conversation

alexfauquette
Copy link
Member

@alexfauquette alexfauquette commented Oct 10, 2022

When moving to the slot, the DateRangeDay is adding styles to empty grid cells which leads to some inconsistencies

Here is a record of the problem when moving the mouse hover the cell

hoverBug.mp4

The reason is that on hover the cell adds a 1px border. We do not see it because component are hidden, but it modifies the layout

@alexfauquette alexfauquette added the bug 🐛 Something doesn't work label Oct 10, 2022
@mui-bot
Copy link

mui-bot commented Oct 10, 2022

These are the results for the performance tests:

Test case Unit Min Max Median Mean σ
Filter 100k rows ms 471.7 886.8 708.4 666.82 168.095
Sort 100k rows ms 525.7 980.7 867.2 778.66 170.372
Select 100k rows ms 181.9 262.9 222.8 223.98 27.587
Deselect 100k rows ms 125 203.8 189.8 178.94 28.528

Generated by 🚫 dangerJS against 85ad2f3

@flaviendelangle
Copy link
Member

diff --git a/packages/x-date-pickers/src/PickersDay/PickersDay.tsx b/packages/x-date-pickers/src/PickersDay/PickersDay.tsx
index ea562295f..9191d61f4 100644
--- a/packages/x-date-pickers/src/PickersDay/PickersDay.tsx
+++ b/packages/x-date-pickers/src/PickersDay/PickersDay.tsx
@@ -184,6 +184,7 @@ const PickersDayFiller = styled('div', {
   ...styleArg({ theme, ownerState }),
   // visibility: 'hidden' does not work here as it hides the element from screen readers as well
   opacity: 0,
+  pointerEvents: 'none',
 }));

The following also fixes the problem, if you don't want the DateRangePickersDay to know why a day is hidden or not.

@LukasTy
Copy link
Member

LukasTy commented Oct 12, 2022

Is it still a problem?
I struggle to reproduce the issue on latest next 🤷

@alexfauquette
Copy link
Member Author

I do not manage to reproduce it either. But Flavien's proposal makes sense even if the bug has been solved by an unknown commit.
Hidden element should not react to the pointer

@flaviendelangle
Copy link
Member

flaviendelangle commented Oct 12, 2022

I can still reproduce it on next with a DateRangeCalendar
I'll prepare a reproduction case if I have some time 👍

@alexfauquette
Copy link
Member Author

alexfauquette commented Oct 12, 2022

I confirm I can reproduce it (and the PR solves the bug) with

import * as React from 'react';
import { DateRangeCalendar } from '@mui/x-date-pickers-pro/DateRangeCalendar';
import { LocalizationProvider } from '@mui/x-date-pickers-pro'
import { AdapterDayjs } from '@mui/x-date-pickers-pro/AdapterDayjs'

export default function PlaygroundExample() {
  return (
    <LocalizationProvider dateAdapter={AdapterDayjs}>
      <DateRangeCalendar />
    </LocalizationProvider>
  );
}

Can not be done in codesandbox because DateRangeCalendar is not currently exported

@LukasTy
Copy link
Member

LukasTy commented Oct 12, 2022

Proposal for a PR title change:
[DateRangePicker] Fix calendar day outside of month layout shifting on hover

@alexfauquette alexfauquette changed the title [DateRangePicker] Fix CSS for calendar on hover [DateRangePicker] Fix calendar day outside of month layout shifting on hover Oct 12, 2022
@alexfauquette alexfauquette merged commit 3721999 into mui:next Oct 12, 2022
@alexfauquette alexfauquette deleted the fix-hover-date-range branch October 12, 2022 13:18
alexfauquette added a commit to alexfauquette/mui-x that referenced this pull request Oct 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants