Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Dropdown directives conflict with bootstrap's JS #2156

Closed
lijuenc opened this issue May 7, 2014 · 18 comments
Closed

Dropdown directives conflict with bootstrap's JS #2156

lijuenc opened this issue May 7, 2014 · 18 comments

Comments

@lijuenc
Copy link

lijuenc commented May 7, 2014

The dropdown directives have a restrict value of CA. This means that if you also have bootstrap.js referenced as a script file, the directives conflict with Bootstrap's JavaScript hooks into the dropdown and dropdown-toggle classes.

See this plunker. Notice that it takes two clicks to open a non-directive dropdown.

http://plnkr.co/edit/AYHYLesd4025dUdfLT7i?p=preview

@lijuenc lijuenc closed this as completed May 7, 2014
@lijuenc lijuenc reopened this May 7, 2014
@chrisirhc
Copy link
Contributor

@Durz , right now there isn't any compatibility with the Bootstrap's Javascript so including Boostrap's JS could have undesirable consequences.
Is there a feature you would like that's provided in the Bootstrap's JS that you can't achieve with UI Bootstrap?

@paulpflug
Copy link

I just ran into the same problem. I think it is sufficient to mention it in the docs.
"don't use data-toggle="dropdown" on your link / button. It will conflict with bootstrap.js"

and thanks to pointing me to the solution @Durz ;)

scenario:
someone is not fully aware of the bootstrap UI dropdown feature (because he uses bootstrap UI mainly for some other great feature) and tries to use plain bootstrap, but it is just not working the way they say ;)

@paulpflug
Copy link

On a second thought, maybe we should prefer to prevent the conflict by overwriting the data-toggle attribute.

@lijuenc
Copy link
Author

lijuenc commented May 7, 2014

@chrisirhc Thanks for that bit of info. I don't have a particular feature that I'm missing. I was updating UI-Bootstrap from 0.10.0 to 0.11.0 for an existing project that has had code written before UI-Bootstrap was brought in (hence the use of bootstrap.js), and found my dropdowns requiring several clicks to open. It wasn't immediately obvious that UI-Bootstrap was conflicting with Bootstrap's JS as I don't think the docs mention that you shouldn't use the two together.

@pkozlowski-opensource
Copy link
Member

@bekos @chrisirhc I wonder if we shouldn't drop C from those directives. It is true that it will require more typing but at least will be explicit....

@bekos
Copy link
Contributor

bekos commented May 7, 2014

Agree to drop the C from our directives. This will be inevitable anyway when we namespace our directives I think.

@pkozlowski-opensource
Copy link
Member

OK, let's drop C then!

bekos added a commit to bekos/bootstrap that referenced this issue May 8, 2014
Fixes angular-ui#2156

BREAKING CHANGES: Both `dropdown` and `dropdown-toggle` are only attribute directives

Before:
  ```html
  <btutton class="dropdown-toggle" ...>
  ```
  After:
  ```html
  <btutton class="dropdown-toggle" dropdown-toggle ...>
  ```
bekos added a commit to bekos/bootstrap that referenced this issue May 8, 2014
Fixes angular-ui#2156

BREAKING CHANGES: Both `dropdown` and `dropdown-toggle` are only attribute directives

Before:
  ```html
  <btutton class="dropdown-toggle" ...>
  ```
  After:
  ```html
  <btutton class="dropdown-toggle" dropdown-toggle ...>
  ```
@lijuenc lijuenc closed this as completed May 14, 2014
@inquire
Copy link

inquire commented Jun 5, 2014

Hi guys! You talked about removing the C, but as i am looking at the latest master, the C is still in there. Did you guys change your mind, or is there another clever way of making it work alongside bootstrap.js?

@sensorii
Copy link

I spent hours discovering this issue myself, finally finding an explanation here so making a note. It would be nice if bootstrap.js and angular-bootstrap.js were compatible. I tried the latest version here and was not able to see resolution of the issue.

bekos added a commit that referenced this issue Jul 22, 2014
Fixes #2156

BREAKING CHANGES: Both `dropdown` and `dropdown-toggle` are only attribute directives

Before:
  ```html
  <btutton class="dropdown-toggle" ...>
  ```
  After:
  ```html
  <btutton class="dropdown-toggle" dropdown-toggle ...>
  ```

Closes #2170
jurassic-c pushed a commit to jurassic-c/bootstrap that referenced this issue Aug 6, 2014
Fixes angular-ui#2156

BREAKING CHANGES: Both `dropdown` and `dropdown-toggle` are only attribute directives

Before:
  ```html
  <btutton class="dropdown-toggle" ...>
  ```
  After:
  ```html
  <btutton class="dropdown-toggle" dropdown-toggle ...>
  ```

Closes angular-ui#2170
@PowerKiKi
Copy link
Contributor

As @inquire mentioned, I think the situation is not clear yet. @bekos create a commit on his fork, but it is not yet available anywhere in this repository. Also that commit probably miss a Breaking Change note somewhere in the Changelog.

@Durz, could you please re-open this issue, until the commit actually get merged ?

(the MIFOSX-1387 "merged" mentioned on this page actually refers to an entirely different project)

@PowerKiKi
Copy link
Contributor

Also I don't see how @bekos commit avoid the conflict. According to the commit message, this is the new syntax that should be used:

Before:

  <button class="dropdown-toggle" ...>

After:

  <button class="dropdown-toggle" dropdown-toggle ...>

But as you can see the CSS class are not modified at all. So wouldn't the original Bootstrap JavaScript still behave exactly as originally described by @inquire and enter in conflict with ui-boostrap directives ?

@lijuenc lijuenc reopened this Sep 18, 2014
@lijuenc
Copy link
Author

lijuenc commented Sep 18, 2014

reopened as requested. From what I can see in the commit diff, the restrict property of the directive was removed completely, rather than being changed from restrict: 'CA' to restrict: 'A'. Was this intended?

@bekos bekos closed this as completed in 192768e Sep 26, 2014
@chrisirhc
Copy link
Contributor

@Durz I believe the default value for restrict is 'A'. However, this changed recently in 1.3, but we haven't gotten around to 1.3 support yet.

With regards to @PowerKiKi 's comment, now dropdown classes aren't linked as directives via ui-bootstrap. As mentioned in the http://getbootstrap.com/javascript/#dropdowns, the data-toggle="dropdown attribute is required, hence, if you use the following line to setup your dropdowns, that should fix compatibility issues (use it instead of targeting the class):

$('[data-toggle=dropdown]').dropdown()

@PowerKiKi
Copy link
Contributor

Thank you for those explanations. Not being familiar with original Bootstrap JavaScript I was under the impression that initialization was automated and we could not have any control on that. Your suggestion totally makes sense, thanks.

ulle pushed a commit to ulle/bootstrap that referenced this issue Oct 22, 2014
Fixes angular-ui#2156

Closes angular-ui#2170

BREAKING CHANGE: Both `dropdown` and `dropdown-toggle` are only attribute directives

Before:
  ```html
  <button class="dropdown-toggle" ...>
  ```
  After:
  ```html
  <button class="dropdown-toggle" dropdown-toggle ...>
  ```
@devniel
Copy link

devniel commented Nov 2, 2014

Thanks @chrisirhc , it works

OronNadiv pushed a commit to lanetix/bootstrap that referenced this issue Nov 18, 2014
Fixes angular-ui#2156

BREAKING CHANGES: Both `dropdown` and `dropdown-toggle` are only attribute directives

Before:
  ```html
  <btutton class="dropdown-toggle" ...>
  ```
  After:
  ```html
  <btutton class="dropdown-toggle" dropdown-toggle ...>
  ```

Closes angular-ui#2170
OronNadiv pushed a commit to lanetix/bootstrap that referenced this issue Nov 18, 2014
Fixes angular-ui#2156

Closes angular-ui#2170

BREAKING CHANGE: Both `dropdown` and `dropdown-toggle` are only attribute directives

Before:
  ```html
  <button class="dropdown-toggle" ...>
  ```
  After:
  ```html
  <button class="dropdown-toggle" dropdown-toggle ...>
  ```
@michaeldjeffrey
Copy link

Is there anywhere where the breaking changes are documented between version? This one just tripped me up, and wondering if there are any more I don't know about.

@karianna
Copy link
Contributor

@michaeldjeffrey Not that I'm aware of - you can look at all of the issues with a angular1.3 label to get a rough idea.

@iKronyck
Copy link

iKronyck commented Feb 2, 2019

thanks @chrisirhc it worked for me in laravel and react js

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

No branches or pull requests