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

[Collapse] Add orientation and horizontal support #20619

Merged
merged 3 commits into from
Jul 3, 2020

Conversation

darkowic
Copy link
Contributor

@darkowic darkowic commented Apr 18, 2020

Breaking changes

  • The collapsedHeight prop was renamed collapsedSize to support the horizontal direction.

    -<Collapse collapsedHeight={40}>
    +<Collapse collapsedSize={40}>

One thing I am not sure about - how do we handle props deprecations? The yarn proptypes is not adding the deprecatedPropType util 🤔

Closes #10051

@darkowic
Copy link
Contributor Author

Oh and another thing - I am not able to run tests because of following error:

$ yarn test:unit --grep Collapse
...
✖ ERROR: No valid exports main found for '/home/darkowic/projects/github/material-ui/node_modules/dom-accessibility-api'

@mui-pr-bot
Copy link

mui-pr-bot commented Apr 18, 2020

@material-ui/core: parsed: +0.13% , gzip: +0.20%
@material-ui/lab: parsed: +0.20% , gzip: +0.27%

Details of bundle changes

Generated by 🚫 dangerJS against 24c0cec

@darkowic
Copy link
Contributor Author

darkowic commented Apr 18, 2020

There are still 2 things I am not sure about the collapse:

  • Why this component needs 2 wrappers?
  • IMHO the wrapper should set width and height to 100% to fill the whole root space:
    2020-04-18_16-03
    after setting the wrapper's height to 100% (the content has height 100%):
    2020-04-18_16-04

@eps1lon
Copy link
Member

eps1lon commented Apr 19, 2020

Oh and another thing - I am not able to run tests because of following error:

What OS are you using and what's the output of node -v?

@darkowic
Copy link
Contributor Author

Oh and another thing - I am not able to run tests because of following error:

What OS are you using and what's the output of node -v?

@eps1lon

$ uname -a
Linux pop-os 5.3.0-7648-generic #41~1586789791~19.10~9593806-Ubuntu SMP Mon Apr 13 17:50:40 UTC  x86_64 x86_64 x86_64 GNU/Linux
$ node -v
v13.5.0

@oliviertassinari oliviertassinari added this to the v5 milestone Apr 19, 2020
@oliviertassinari oliviertassinari added the new feature New feature or request label Apr 19, 2020
@darkowic
Copy link
Contributor Author

@oliviertassinari I see you added v5 label - when do you think we can release it?. Why not release it in some 4.x version? I would love to use it (I use it now - I copied the whole component into my source). I tried to not introduce any breaking changes.

@oliviertassinari
Copy link
Member

@darkowic We are freezing all new features from the v4 branch.

@darkowic
Copy link
Contributor Author

😒 Well, then I'm waiting for v5-alpha.1 🚀

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Apr 20, 2020
@mbrookes
Copy link
Member

@darkowic You can target the next branch with this.

@darkowic darkowic changed the base branch from master to next June 23, 2020 21:30
@darkowic
Copy link
Contributor Author

Updated ;) One unit tests is failing:

  it('can fallback to findDOMNode in a StrictMode theme', () => {

with TypeError: Cannot read property 'style' of null when trying to get wrapperRef.current and some browser tests are failing with similar error - any tips?

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Jun 24, 2020
@eps1lon eps1lon self-assigned this Jun 24, 2020
packages/material-ui/src/Collapse/Collapse.js Outdated Show resolved Hide resolved
packages/material-ui/src/Collapse/Collapse.js Outdated Show resolved Hide resolved
packages/material-ui/src/Collapse/Collapse.js Outdated Show resolved Hide resolved
@mbrookes
Copy link
Member

Marked as breaking in anticipation of the removal of collapsedHeight...

@darkowic
Copy link
Contributor Author

btw yarn prettier command from contribution guide doesn't work

@mbrookes
Copy link
Member

@darkowic What error are you getting?

@darkowic
Copy link
Contributor Author

@mbrookes

[darkowic@pop-os] ~/projects/github/material-ui (10051_horizontal_collapse)
$ yarn prettier
yarn run v1.22.4
$ node ./scripts/prettier.js
prettier.js [mode]

formats codebase

Positionals:
  mode  "write" | "check-changed" | "write-changed"
                                             [string] [default: "write-changed"]

Options:
  --help  Show help                                                    [boolean]

Error: Command failed: git rev-parse next
fatal: ambiguous argument 'next': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

    at ChildProcess.exithandler (child_process.js:303:12)
    at ChildProcess.emit (events.js:315:20)
    at maybeClose (internal/child_process.js:1051:16)
    at Socket.<anonymous> (internal/child_process.js:442:11)
    at Socket.emit (events.js:315:20)
    at Pipe.<anonymous> (net.js:670:12) {
  killed: false,
  code: 128,
  signal: null,
  cmd: 'git rev-parse next',
  stdout: 'next\n',
  stderr: "fatal: ambiguous argument 'next': unknown revision or path not in the working tree.\n" +
    "Use '--' to separate paths from revisions, like this:\n" +
    "'git <command> [<revision>...] -- [<file>...]'\n"
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Fortunately, yarn prettier:all works ;)

@mbrookes
Copy link
Member

Looks like you don't have a local next branch for listChangedFiles() to compare with. (Which pretter:all doesn't require.) Should probably have a defensive check...

@mbrookes
Copy link
Member

Something's off with the horizontal collapse - it slides to the right rather than collapsing to the left when collapsedSize is set.

@eps1lon
Copy link
Member

eps1lon commented Jun 27, 2020

@darkowic Fetch to upstream remote again i.e. git fetch upstream if upstream is pointing to https://github.com/mui-org/material-ui.

@darkowic
Copy link
Contributor Author

Something's off with the horizontal collapse - it slides to the right rather than collapsing to the left when collapsedSize is set.

@mbrookes hmm how it should work? Do we want to add some prop that defines which direction it is animated?

@mbrookes
Copy link
Member

It should behave the same as without collapsedSize, but stop collapsing at collapsedSize width (as it does with vertical).

@eps1lon eps1lon added the PR: out-of-date The pull request has merge conflicts and can't be merged label Jul 1, 2020
@eps1lon
Copy link
Member

eps1lon commented Jul 1, 2020

@darkowic Could you update this PR please with the latest version of the next branch?

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Jul 1, 2020
@darkowic
Copy link
Contributor Author

darkowic commented Jul 1, 2020

Yes, I will do it together with the fix/solution for collapse animation orientation

* BREAKING CHANGE: Remove collapsedHeight property - use collapsedSize

(mui#10051)
@darkowic
Copy link
Contributor Author

darkowic commented Jul 2, 2020

collapse_demo

Rebased and improved demo. Actually it was looking weird because of space-between ;)

🚢 🎉

Comment on lines +256 to +258
className={clsx(classes.wrapperInner, {
[classes.horizontal]: isHorizontal,
})}
Copy link
Member

Choose a reason for hiding this comment

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

What about we use Slider's approach?

https://github.com/mui-org/material-ui/blob/65d036e8aab5e0fe9e3efbf788daa8af8db57757/packages/material-ui/src/Slider/Slider.js#L192

Suggested change
className={clsx(classes.wrapperInner, {
[classes.horizontal]: isHorizontal,
})}
className={classes.wrapperInner}

@@ -41,15 +40,15 @@ export const styles = (theme) => ({
display: 'flex',
width: '100%',
'&$horizontal': {
width: 'initial',
Copy link
Member

Choose a reason for hiding this comment

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

@@ -11,13 +11,12 @@ import { useForkRef } from '../utils';
export const styles = (theme) => ({
/* Styles applied to the container element. */
container: {
position: 'relative',
Copy link
Member

Choose a reason for hiding this comment

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

Seem irrelevant

@oliviertassinari oliviertassinari removed the request for review from dimitropoulos July 2, 2020 23:43
@eps1lon eps1lon merged commit 64cbf68 into mui:next Jul 3, 2020
@eps1lon
Copy link
Member

eps1lon commented Jul 3, 2020

@darkowic Great work, thanks!

@zachsa
Copy link

zachsa commented Jul 27, 2020

Hi, I've been experimenting with this and I have found that the <Collapse /> component takes up the whole horizontal space with this structure:

<Grid container>
  <Collapse orientation="horizontal" in={showSidebar}>
    <Grid item xs={4}>
      <Sidebar />
    </Grid>
  </Collapse>

  <Grid item xs>
    <ResultList />
  </Grid>
</Grid>

In this case the Collapse component, when in = true, renders as 100% the width of the <Grid container>. I'm not actually sure that I'm using Grid correctly... But when I use any other Transition this is NOT the case. For example, replacing Collapse with

<Slide direction="right" unmountOnExit in={showSidebar}>
  ...
</Slide>

Then the layout behaves correctly (in that the slide component renders 'transparently', with the child Grid component sizing working as expected).

Looking at the HTML.

The Slide component gets classNames associated with the Grid (which I assume is the children?):

<div class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-4" style="transform: none; transition: transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms;" />

Whereas with the Collapse component, unlike with the Slide, no inline styles are giving, and the classes don't include any classes from the children:

<div class="MuiCollapse-container MuiCollapse-horizontal MuiCollapse-entered" style="min-width: 0px;">
  <div class="MuiCollapse-wrapper MuiCollapse-horizontal">
    <div class="MuiCollapse-wrapperInner MuiCollapse-horizontal">
...

Is this intended?

Rewriting my JSX:

<Grid container>
  <Collapse
    timeout={3000}
    className={clsx({
      'MuiGrid-root': true,
      'MuiGrid-item': true,
      'MuiGrid-grid-xs-4': showSidebar ? true : false,
    })}
    orientation="horizontal"
    in={showSidebar}
  >
    <Grid item xs={showSidebar ? 12 : 4}>
      <Sidebar />
    </Grid>
  </Collapse>

  <Grid item xs>
    <ResultList />
  </Grid>
</Grid>

This somewhat achieves what I'm looking for but in a very jumpy, unsatisfactory way (the timout={3000} allows me to see where the problems are).

I apologise if I'm misusing the Transition component in this case! If so, I would be super grateful for pointers in the correct direction.

@eps1lon
Copy link
Member

eps1lon commented Jul 27, 2020

@zachsa Please open a new issue and fill out the template. PRs are not monitored for potential issues.

@zachsa
Copy link

zachsa commented Jul 28, 2020

Thank you @eps1lon - I've written up an issue here: #21971

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change new feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Collapse] Transition for width instead of height?
6 participants