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

Reintroduce Hidden component #26408

Closed
GDownes opened this issue May 21, 2021 · 5 comments · Fixed by #26908
Closed

Reintroduce Hidden component #26408

GDownes opened this issue May 21, 2021 · 5 comments · Fixed by #26908
Assignees
Labels
component: Hidden The React component. deprecation New deprecation message new feature New feature or request v5.x migration
Milestone

Comments

@GDownes
Copy link

GDownes commented May 21, 2021

Reintroduce the hidden component.

https://material-ui.com/components/hidden/

The removal of the hidden compatibility breaks backwards compatibility.
Currently the sx property makes it difficult to replicate the functionally of the hidden component.
I think it has been prematurely removed.

For example:

<Hidden smDown><Button display='flex' /><Hidden/>

becomes,

<Button sx={{ display: { xs: "none", sm: "none", md: "flex", lg: "flex", xl: "flex" }}} />

Having to list all the breakpoints in the example above isn't ideal. Hidden supported this use case well.

@GDownes GDownes added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label May 21, 2021
@eps1lon eps1lon added component: Hidden The React component. new feature New feature or request and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels May 21, 2021
@mnajdova
Copy link
Member

@GDownes you don't need to specify all breakpoints, see https://github.com/mui-org/material-ui/pull/26348/files Does this clarify things?

-<Hidden implementation="css" smDown><Button' /></Hidden>
+<Button sx={{ display: { xs: 'none', sm: 'flex' } }} />

See https://codesandbox.io/s/nifty-banzai-gb6co?file=/index.js

@mnajdova mnajdova changed the title Reintroduce Hidden component [Hidden] How to replace smDown May 21, 2021
@GDownes
Copy link
Author

GDownes commented May 21, 2021

@mnajdova Thanks for the quick reply:
It's seems I do need to specify all breakpoints:

See: https://codesandbox.io/s/upbeat-rosalind-6ch0t?file=/index.js

In this example I'd expect xs to also be hidden as I've marked a higher breakpoint as hidden but it shows

@mnajdova
Copy link
Member

@GDownes it works the other way around, the object in the sx breakpoints specifies up(), that's why you need to specify the lowest breakpoint (xs to be hidden), and the next breakpoint for which you want the component to be shown. On the example you've sent, change sm with xs and it would be hidden for both xs and sm

@GDownes
Copy link
Author

GDownes commented May 21, 2021

@mnajdova Thanks for the clarification. That makes sense, closing. I still think that Hidden should be deprecated more slowly.

@GDownes GDownes closed this as completed May 21, 2021
@eps1lon eps1lon changed the title [Hidden] How to replace smDown Reintroduce Hidden component May 26, 2021
@oliviertassinari
Copy link
Member

oliviertassinari commented May 31, 2021

I have stopped listening to issues for the last 3 weeks and will likely continue going forward. I was planning to open the same issue when I realized it was already created. It seems that the removal of the <Hidden> component was premature. We got a lot more people complaining about this one than most of the other BCs.

My main concern is that the migration path is only fully available since v5, people on v4 don't have a smooth transition. I propose we introduce the component back but deprecated. cc @mui-org/core.

@oliviertassinari oliviertassinari added this to the v5-beta milestone May 31, 2021
@oliviertassinari oliviertassinari modified the milestones: v5-beta, v5 Jun 15, 2021
@oliviertassinari oliviertassinari added the deprecation New deprecation message label Jun 16, 2021
@siriwatknp siriwatknp self-assigned this Jun 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: Hidden The React component. deprecation New deprecation message new feature New feature or request v5.x migration
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants