ui-select icon indicating copy to clipboard operation
ui-select copied to clipboard

bug 0.9.4 CSS broken: button with caret moved to next line

Open iyeldinov opened this issue 11 years ago • 18 comments

iyeldinov avatar Dec 10 '14 15:12 iyeldinov

Here's how it looks:

screen shot 2014-12-11 at 14 43 42

Additionally, it now looks weird, when container width is not specified:

screen shot 2014-12-11 at 14 43 28

0.9.2 looks:

screen shot 2014-12-11 at 14 44 43

screen shot 2014-12-11 at 14 44 58

sebastian-zarzycki avatar Dec 11 '14 13:12 sebastian-zarzycki

Angular 1.3.6 / Bootstrap 3.3.1, ui-select bootstrap theme.

sebastian-zarzycki avatar Dec 11 '14 13:12 sebastian-zarzycki

I'm also seeing this problem with the bootstrap theme since updating to 0.9.4 to use the allow-clear functionality on single select controls.

RobPierce avatar Dec 12 '14 11:12 RobPierce

@amcdnl I think this was caused by https://github.com/angular-ui/ui-select/commit/597bb218f44d23c2cf8ba31646b2766039d3b1de#diff-8156b6c885865950b8b7f9e2c857096eR1146 and/or https://github.com/angular-ui/ui-select/commit/597bb218f44d23c2cf8ba31646b2766039d3b1de#diff-93955e143fd7bf0d3c1dd8bcf781c3f3R43 - can you take a look?

brianfeister avatar Dec 12 '14 16:12 brianfeister

I don't think that using bootstrap's grid inside button is a good idea.

syabro avatar Dec 14 '14 13:12 syabro

+1 I know that I'm not helping, but... Somebody found any workaround already?

jossemarGT avatar Dec 15 '14 22:12 jossemarGT

What would be helpful is if someone could try to debug the issue. If someone can post working / fixed code, then I can get a hotfix merged.

brianfeister avatar Dec 15 '14 22:12 brianfeister

I have found that if I set the width to at least 300px then it won't wrap. I don't understand why there are col-* classes inside a btn-group. That makes no sense to me. This is breaking a lot of things in our app currently. The only thing I can think of is to remove these classes because they are unnecessary. The only other fix is to keep your selects above 300px width.

https://github.com/angular-ui/ui-select/blob/master/src/bootstrap/match.tpl.html#L2 https://github.com/angular-ui/ui-select/blob/master/src/bootstrap/match.tpl.html#L6 https://github.com/angular-ui/ui-select/blob/master/src/bootstrap/match.tpl.html#L9

SerenadeX avatar Dec 16 '14 20:12 SerenadeX

After reading through the code and playing with this for a bit I understand why we are using the col classes. It allows us to fill the width. I just don't understand why it stops working when a dropdown is smaller than 300px

SerenadeX avatar Dec 16 '14 20:12 SerenadeX

The reason is because bootstrap columns themselves have a minimum width, hence they're not appropriate in this context. They respond to responsive breakpoints and become full-width at those breakpoints.

brianfeister avatar Dec 16 '14 20:12 brianfeister

I found that if I changed the col to be a col-md-9 instead of a col-md-11 then it kept it from wrapping. Also the small screen size keeps it from wrapping

SerenadeX avatar Dec 16 '14 20:12 SerenadeX

Its just a hacky way to solve this. And I agree that columns aren't appropriate in this context. I'm trying to find a way to get the buttons to fill the parent container without using bootstrap columns

SerenadeX avatar Dec 16 '14 20:12 SerenadeX

Thanks for the feedback @SerenadeX, for now I'd like to wait for a response from @DanielClausen

brianfeister avatar Dec 16 '14 20:12 brianfeister

Hey, this is my fix for that issue, col- classes are not a good option here IMHO, instead I use flexbox, which is extremely easy to setup... but IE10+ only:

// Overwrite ui-select template, to use flexbox model instead of buggy bootstrap grid model
angular.module("ui.select").run([
    "$templateCache",
    function($templateCache) {
        $templateCache.put("bootstrap/match.tpl.html", "<div style=\"display: flex\" class=\"btn-group ui-select-match btn-block\" ng-hide=\"$select.open\" ng-disabled=\"$select.disabled\" ng-class=\"{\'btn-default-focus\':$select.focus}\"><button style=\"flex-grow: 1;\" type=\"button\" class=\"btn btn-default\" tabindex=\"-1\" ng-click=\"$select.activate()\"><span ng-show=\"$select.isEmpty()\" class=\"text-muted\">{{$select.placeholder}}</span> <span ng-hide=\"$select.isEmpty()\" ng-transclude=\"\"></span></button> <button class=\"btn btn-default\" ng-if=\"$select.allowClear && !$select.isEmpty()\" ng-click=\"$select.select(undefined)\"><span class=\"glyphicon glyphicon-remove ui-select-toggle\"></span></button> <button class=\"btn btn-default\" ng-click=\"$select.activate()\"><span class=\"caret ui-select-toggle\" ng-click=\"$select.toggle($event)\"></span></button></div>");
    }]);

PowerKiKi avatar Dec 23 '14 15:12 PowerKiKi

+1

Please fix this issue. Meanwhile I roled back the update to the updated version.

seinavco avatar Dec 28 '14 14:12 seinavco

I fixed this in a different way from what was mentioned above; I used calc. My solution's very specific for my use case, but it basically boils down to this:

.ui-select-match > button.col-sm-10 {
    width: calc(100% - 34px);
}

.ui-select-match > button.col-sm-8 {
    width: calc(100% - 73px);
}

This means that the caret button will need to be a fixed width (this is easily doable in my experience), and you will need to apply a class to this button if clear selection is enabled and something is selected. That class will need to override the calc width, but that's also easily doable.

While I'm sure that using something like flex-box might be more desirable for other reasons, I've found the calc() is pretty simple and very well supported. It's how I'd suggest solving this issue, personally.

Morgul avatar Jan 04 '15 01:01 Morgul

Faced with the same issue.

kashesandr avatar Jan 12 '15 15:01 kashesandr

Fix released in v0.9.6

brianfeister avatar Jan 12 '15 20:01 brianfeister