Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Clicking on ui-select's caret does not toggle the dropdown #1797

Closed
artuska opened this issue Sep 8, 2016 · 20 comments
Closed

Clicking on ui-select's caret does not toggle the dropdown #1797

artuska opened this issue Sep 8, 2016 · 20 comments
Labels

Comments

@artuska
Copy link

artuska commented Sep 8, 2016

Clicking exactly on

<i class="caret pull-right" ng-click="$select.toggle($event)"></i>

does not toggle the dropdown.

Angular: 1.4.9
UI-Select: 0.19.4
Bootstrap theme

@Jefiozie
Copy link
Contributor

Jefiozie commented Sep 8, 2016

As described in the issue template you should add a plunker as this is needed to see the problem.

@decherneyge
Copy link

decherneyge commented Sep 20, 2016

seems to be related to search-enabled="false"

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

UPDATE:
based on @katsos answer below I ended up doing the following:

$("body").on('click', '.ui-select-toggle>i.caret', function(e){
            e.stopPropagation();

            var parent = $(this).parent('.ui-select-toggle');
            if(parent){
                parent.click();
            }

        });

@jbarrus
Copy link

jbarrus commented Sep 21, 2016

Looks like it was probably introduced with this commit - be0d301

@katsos
Copy link

katsos commented Sep 26, 2016

Using jQuery I did it this way:

initFiltersEvents() {
        let multiFilters = $('.filterClass');

        /* For each filter, disable propagation of input and trigger input on click. */
        multiFilters.each( (index, multiFilter) => {
            let input = $(multiFilter).find('.ui-select-search');

            input.on('click', event => event.stopPropagation() );

            $(multiFilter).on('click', event => {
                event.stopPropagation();
                input.trigger('click');
            });
        });
    }

@amihaylov
Copy link

I'm also experiencing the issue (angular 1.5.8, ui-bootstrap 2.2.0 (if applicable) and tested with ui-select from 0.19.4 to 0.18.0). However changing search-enabled to true or false or removing it completely didnt have any effect. Turned out that the issue is with opacity of the ui-select-dropdown inside the ui-select-container so as a workaround I am toggling it whether the container has class open or not.

@artuska
Copy link
Author

artuska commented Oct 24, 2016

As a temporary fix I used CSS and added z-index for the span and .caret elements so the span is above and overlapping the .caret and user always clicks on span not on .caret.

@troywoy
Copy link

troywoy commented Nov 14, 2016

@artuska, what was the CSS for your solution and what span did you apply it to? I have a hunch that your solution may just hack my way into a working ui-select as well.

Edit:
I'm using this...

.ui-select-toggle { z-index: 1; }
.caret { z-index: -1; }

@mzealey
Copy link

mzealey commented Dec 6, 2016

Issue for us too.

@Red-3
Copy link

Red-3 commented Dec 13, 2016

+1 - this is something that is causing us unexpected grief

@Red-3
Copy link

Red-3 commented Dec 13, 2016

@twh1808 Thanks for your CSS workaround.

I found that ui-select also has a wide padding on the ui-select-toggle which prevented clicking on the right half of the arrow glyph in my case.
Had to suppress padding on the right to overcome it:

.ui-select-toggle { z-index: 1; padding-right: 4px; }
.caret { z-index: -1; }

@troywoy
Copy link

troywoy commented Dec 13, 2016

@Red-3, I haven't seen much activity on this so hopefully it's just a temporary workaround but I'm not so sure I'll ever be able to remove it. Glad it was of help to you, @artuska is probably the one to thank though, as his original comment made me realize this could be easily overcome with CSS rather than hack-y JavaScript.

I looked into the UI-Select examples to verify your padding comment, and yeah you would have to do something to account for the right side as the element only lays on half of the arrow. I worked with another colleague skinning a large application built on Angular and Angular UI Bootstrap, and in our efforts we changed the padding size and arrow positioning such that this specific issue didn't apply to us.

Good catch for others, though!

@mzealey
Copy link

mzealey commented Dec 14, 2016

I'm using bootstrap + font-awesome with non-transparent search boxes. I had to do the following less to work around it:

.ui-select-bootstrap {
    .ui-select-toggle > .caret { display: none }
    .ui-select-toggle::after {
        .glyphicon();
        content: @fa-var-caret-down;
        position: absolute;
        right: 1em;
        padding-top: 4px;
    }
}

@Jefiozie
Copy link
Contributor

Maybe somebody could make a good PR for this?

@Red-3
Copy link

Red-3 commented Jan 24, 2017

@mzealy - Thank you.
If you're not using LESS but have font-awsome.css in the mix, try:

.ui-select-bootstrap {
  .ui-select-toggle > .caret {
    display: none;
  }
  .ui-select-toggle::after {
    font-family: FontAwesome;
    content: "\f0d7";
    position: absolute;
    right: 1em;
  }
}

@Jefiozie
Copy link
Contributor

Looks like the pr #2011 has fixed the problem. Could you verify?

@Jefiozie Jefiozie reopened this Jun 26, 2017
@kudryk
Copy link

kudryk commented Jul 26, 2017

Is there an ETA for a 0.19.9 release to get this fix?

@Sidd27
Copy link

Sidd27 commented Dec 16, 2017

In bower version it still have the same code

ctrl.toggle = function (e) { if (ctrl.open) { ctrl.close(); e.preventDefault(); e.stopPropagation(); } else { ctrl.activate(); } };

Please update the bower version

@rmeja
Copy link

rmeja commented Dec 17, 2018

Is it possible to build a new version that contains this fix ? 😉

@horlescup
Copy link

Can we have a new release please? I would like to have this issue fixed.

@ErikAGriffin
Copy link

So it looks like this was indeed fixed by the PR #2011 on June 15 2017, but a release was never made since then. Are there any maintainers of this repository able to make a new release of the master branch?

Otherwise someone with some time on their hands could create a fork and publish a new release to npm under a different name

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

No branches or pull requests