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

[CalendarPicker] Prevent getting focus when autoFocus=false #6304

Merged
merged 1 commit into from Sep 28, 2022

Conversation

alexfauquette
Copy link
Member

@alexfauquette alexfauquette commented Sep 27, 2022

In DatePicker doc page the focus is caught by the year picker.

This PR should fix this bug

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

mui-bot commented Sep 27, 2022

These are the results for the performance tests:

Test case Unit Min Max Median Mean σ
Filter 100k rows ms 561 970.6 704.6 742.22 167.698
Sort 100k rows ms 609.7 1,261.2 609.7 945.06 219.471
Select 100k rows ms 215.6 352.4 280.2 274.38 48.096
Deselect 100k rows ms 156.6 345.5 182.8 209.68 68.638

Generated by 🚫 dangerJS against 20ce901

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.

Nice fix

I did not test it, but what is preventing us from doing this update in the render like we do in usePickerState ?
React tends to recommend that approach over an effect: https://fr.reactjs.org/docs/hooks-faq.html#how-do-i-implement-getderivedstatefromprops

@alexfauquette
Copy link
Member Author

@flaviendelangle I don't get to which part of usePickerState you are referring to

@flaviendelangle
Copy link
Member

flaviendelangle commented Sep 27, 2022

@alexfauquette

// Set the draft and committed date to equal the new prop value.
if (!valueManager.areValuesEqual(utils, dateState.committed, value)) {
setDate({ action: 'setCommitted', value, skipOnChangeCall: true });
}

@alexfauquette
Copy link
Member Author

It's not possible because it updates multiple components, and apparently, you should not update your parents during the render phase. Only inside effect.

I assume the proposed technic to derive state from props only works if the state is limited to the current component

@flaviendelangle
Copy link
Member

It's not possible because it updates multiple components, and apparently, you should not update your parents during the render phase. Only inside effect.

Make sense 👍

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.

OK to merge it as is 👍

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

3 participants