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

[test] disabled prop disable calendar days #4645

Merged
merged 9 commits into from
May 9, 2022

Conversation

alexfauquette
Copy link
Member

@alexfauquette alexfauquette commented Apr 25, 2022

Fix #4594 by testing the corrected bug
Fix #4400
Fix #4650

In readOnly mode

  • edit buttons appear normal, but do nothing
  • navigation is enabled between months and views

In disabled mode

  • edit buttons are disabled
  • navigation is enabled between views but not months
  • Special case of range picker month navigation between the first and last month of the selected range

@mui-bot
Copy link

mui-bot commented Apr 25, 2022

These are the results for the performance tests:

Test case Unit Min Max Median Mean σ
Filter 100k rows ms 288.6 515.9 478 414.5 100.802
Sort 100k rows ms 525.4 1,027.7 779.1 837.18 179.521
Select 100k rows ms 163.9 319.7 187.8 209.22 56.004
Deselect 100k rows ms 109.5 206.9 146.3 159 37.824

Generated by 🚫 dangerJS against 42f97ce

@alexfauquette alexfauquette marked this pull request as ready for review April 25, 2022 08:32
@@ -67,4 +67,22 @@ describe('<StaticDatePicker />', () => {
expect(getYearButton(2030)).to.have.attribute('disabled');
expect(getYearButton(2031)).not.to.have.attribute('disabled');
});

it('prop `disabled` – disables all days', () => {
Copy link
Member

Choose a reason for hiding this comment

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

In other tests, they do the same check for readOnly, I did not look into those for now but maybe it also make sense here.

Copy link
Member Author

Choose a reason for hiding this comment

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

The other readOnly tests only check that the views are not accessible from the pickers. i.e. if you click on the calendar, it does not open the calendar view

I observed that the behavior, of disable/readOnly is well supported only on the StaticDatePicker. I opened a follow-up issue to fix the other static components #4650

I think static pickers are not used or rarely with disabled and even less with readOnly, so I put it in needs upvote

@@ -148,11 +148,11 @@ export function PickersCalendarHeader<TDate>(props: PickersCalendarHeaderProps<T
const selectPreviousMonth = () => onMonthChange(utils.getPreviousMonth(month), 'right');

const isNextMonthDisabled = useNextMonthDisabled(month, {
disableFuture: disableFuture || disabled,
Copy link
Member Author

Choose a reason for hiding this comment

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

disableFuture is disabling compare to the current day, not the selected one, so it does not make sense, especially for the range picker. I moved the responsibility to adapt minDate/maxDate when picker is disabled to the parent

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label May 2, 2022
@github-actions
Copy link

github-actions bot commented May 2, 2022

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label May 2, 2022
Copy link
Member

@flaviendelangle flaviendelangle left a comment

Choose a reason for hiding this comment

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

I am not very familiar with the readOnly pattern
Should the hover background be disabled on readOnly when hovering a day in the DayPicker ?

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label May 6, 2022
@github-actions
Copy link

github-actions bot commented May 6, 2022

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@alexfauquette
Copy link
Member Author

I never used readOnly in an application. I looked at other components, and it seems the only difference is that you can not modify the content.

I don't thin readOnly impacts the visual feedback. For example, the Select has the same visual feedback on hover, and when you click on it, it looks like a focused field but does not open the menu

https://mui.com/material-ui/react-select/#other-props

@flaviendelangle
Copy link
Member

OK, I don't get the goal of this prop but if it is the same elsewhere

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label May 9, 2022
@alexfauquette alexfauquette merged commit 192db15 into mui:master May 9, 2022
@alexfauquette alexfauquette deleted the test-days-disabled branch May 9, 2022 09:34
@flaviendelangle
Copy link
Member

@alexfauquette the tests are failing on Safari, we probably need to early return (see other similar tests)

Safari 13.1.2 (Mac OS 10.15.6) <ClockPicker /> should display options, but not update value when readOnly prop is passed FAILED
	undefined is not a constructor (evaluating 'new window.Touch(Object.assign({
	      target,
	      identifier: 0
	    }, opts))')
	/tmp/_karma_webpack_806820/commons.js:91233:64
	map@[native code]
	fireTouchChangedEvent@/tmp/_karma_webpack_806820/commons.js:91233:39
	/tmp/_karma_webpack_806820/commons.js:175764:38
Safari 13.1.2 (Mac OS 10.15.6) <ClockPicker /> should display disabled options when disabled prop is passed FAILED
	undefined is not a constructor (evaluating 'new window.Touch(Object.assign({
	      target,
	      identifier: 0
	    }, opts))')
	/tmp/_karma_webpack_806820/commons.js:91233:64
	map@[native code]
	fireTouchChangedEvent@/tmp/_karma_webpack_806820/commons.js:91233:39
	/tmp/_karma_webpack_806820/commons.js:175787:38

@zannager zannager added test component: pickers This is the name of the generic UI component, not the React module! labels Jan 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: pickers This is the name of the generic UI component, not the React module! test
Projects
None yet
4 participants