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 with flex elements #22758

Closed
wants to merge 3 commits into from
Closed

Collapse with flex elements #22758

wants to merge 3 commits into from

Conversation

Johann-S
Copy link
Member

@Johann-S Johann-S commented Jun 6, 2017

Detect if the element use flexbox, if it's the case add .flexshow

  • Add Visual test
  • Detect all posible flex values (inline-flex, flex, etc...)

We detect flex by creating hidden div(s) and we add each class to this hidden div to detect if this div is displayed in flex mode or not.

We do that only when we call the constructor of Collapse plugins that's why I added an update method if the collapsible element change, to detect once again the appropriate show class

Close : #22600

/CC : @mdo

// Detect flex for inline style
let useFlex = $(this._element).css('display').indexOf('flex') !== -1

// Create a wrapper to hide our flex detection
Copy link
Member

@glebm glebm Jun 7, 2017

Choose a reason for hiding this comment

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

Can you check getComputedStyle(this._element).display instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

I can use that for the line 316 yes, but not for the detection below because getComputedStyle return the current applied style and that's not what I want here.
I want to know if they are a class which contain a flex display

@Johann-S Johann-S added this to the v4.0.0-beta milestone Jun 7, 2017
@mdo
Copy link
Member

mdo commented Jun 15, 2017

Is anything here considered to be a breaking change @Johann-S? Might be beneficial to wait for Beta 2 to address this.

@Johann-S
Copy link
Member Author

That's right this can wait for beta 2

@Johann-S Johann-S removed this from the v4.0.0-beta milestone Jun 15, 2017
const tabClass = this._element.classList

// Detect flex for inline style
let useFlex = $(this._element).css('display').indexOf('flex') !== -1
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

I switched to includes but they are no support on IE 10 so back to indexOf

Copy link
Member

Choose a reason for hiding this comment

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

But it's transpiled isn't it?

Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't checked but unit tests failed

Copy link
Member

Choose a reason for hiding this comment

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

But since we use babel it should be taken care of. Please try one more time.

Copy link
Member

Choose a reason for hiding this comment

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

Just keep in mind we can do this if we just load the babel polyfill and use ES6 methods. Not sure what the exact size diff is, just thinking out loud for another PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you know which polyfill to use ? I can make a test 👍

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

I checked babel-polyfill and currently when we import babel-polyfill we will import all the available polyfill not the includes one so for now we should merge this PR and open an issue on how to integrate babel-polyfill with only specific es6 polyfill

Copy link
Member

Choose a reason for hiding this comment

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

No worries, it's not so important currently as long as we don't use features that aren't available for the browsers we support.

</div>

<script src="../../../docs/assets/js/vendor/jquery-slim.min.js"></script>
<script src="../../../assets/js/vendor/jquery-slim.min.js"></script>
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, how did it work without this?

Copy link
Member Author

Choose a reason for hiding this comment

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

It didn't work before that change and yes it's an unrelated change

@@ -226,6 +226,10 @@ Shows a collapsible element. **Returns to the caller before the collapsible elem

Hides a collapsible element. **Returns to the caller before the collapsible element has actually been hidden** (i.e. before the `hidden.bs.collapse` event occurs).

#### `.collapse('update')`

Update a collapsible element if this element changed during his lifetime
Copy link
Member

Choose a reason for hiding this comment

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

its lifetime

Copy link
Member

Choose a reason for hiding this comment

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

And maybe add a . at the end.

@Johann-S Johann-S force-pushed the v4-collapse-flex branch 2 times, most recently from 41bdf59 to 190a76f Compare August 17, 2017 17:22
@@ -226,6 +226,10 @@ Shows a collapsible element. **Returns to the caller before the collapsible elem

Hides a collapsible element. **Returns to the caller before the collapsible element has actually been hidden** (i.e. before the `hidden.bs.collapse` event occurs).

#### `.collapse('update')`

Update a collapsible element if this element changed during its lifetime.
Copy link
Member

Choose a reason for hiding this comment

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

How about: "Update a collapsible element if it changed during its lifetime."

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep that's better thanks 👍 I'll update that soon

@Johann-S
Copy link
Member Author

For me everything is fine @mdo so this one can be merged 👍

@vanillajonathan
Copy link
Contributor

Keep in mind that the other .flex-* classes are separated with a hyphen.
Example .flow-row, .flex-column, .flex-wrap, etc.'.

Perhaps .flex-show should be considered.

}

tr {
&.collapse.show {
&.collapse.show,
&.collapse.flexshow {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should .flexshow be named .flex-show to be consistent with the hyphen separation used by the other .flex-* classes?

@Johann-S
Copy link
Member Author

Not sure to keep that PR, because I have to create an hidden div to detect if folks use flex attributes or not, a better solution would be CSS one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants