Skip to content

Multiple input-group-addon support #18500

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

Merged
merged 2 commits into from
Feb 8, 2016
Merged

Conversation

vicary
Copy link

@vicary vicary commented Dec 9, 2015

Patch remade from v4-dev.

Fixes #17927, see this plunker for a live demo.

1. Invert `:first-child` into `:not(:last-child)` and vice versa
2. Remove double border at the left of `.form-control`
3. Shifts negative margins of `.btn` and `.btn-group` to retain
rightmost border when using at the left of `.form-control`.
@cvrebert
Copy link
Collaborator

cvrebert commented Dec 9, 2015

There seems to be a minor bug in your code regarding the :focus border of .form-controls in input groups:
missing-left-border

Note the lack of blue border on the left in the area indicated by the red rectangle I added.

> .btn,
> .btn-group {
z-index: 2;
margin-left: (-$input-btn-border-width);
margin-left: (-$input-btn-border-width) * 2;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't quite understand why you're now doubling here.

Copy link
Author

Choose a reason for hiding this comment

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

Kind of a see-sawing situation, because the original .input-group-btn has double borders in your rectangle, while .input-group-addon does not.

@vicary
Copy link
Author

vicary commented Dec 10, 2015

This fix in fact presented an existing issue of double borders in another way, we could limit the PR to one single fix and make another PR for this one.

Further on the border issue:

I just came up with an alternative approach, look at the end of the file.

Basically I use negative left margin to create an overlap on the double borders.

But this introduce a counter-overlap when the mouse cursor hovers on a .form-control with an .input-group-btn on the left hand side is focused. Basically because of the following behavior.

@include hover-focus-active {
  z-index: 3;
}

At this point we are back to the original style, with the double border in .input-group-btn.

The second fix is specifically for .input-group-btn which involves the use of the siblings selector ~, not sure if the desired compatibility allows so.

@cvrebert
Copy link
Collaborator

Your "alternative approach" sounds reasonable to me.

@vicary
Copy link
Author

vicary commented Dec 11, 2015

After a some crunching I merged two fix into a more simple one, see this plunk.

Gist is also updated to reflect the change.

It does the work way better than the previous attempts.

@vicary
Copy link
Author

vicary commented Dec 14, 2015

Gave another check on the demo on another machine and found .input-group-btn still has double borders, that means the original patch is in fact necessary.

  1. Double border on the left (Current situation)
    screen shot 2015-12-14 at 11 41 56 am

  2. Double border on the right
    screen shot 2015-12-14 at 11 42 08 am
    This is done by adding

    .input-group-btn + .form-control {
      margin-left: -1px;
    }
  3. Finally
    screen shot 2015-12-14 at 11 42 19 am

    This, again, incorporates the double negative margin in my first commit.

    &:not(:first-child) {
      > .btn,
      > .btn-group {
        z-index: 2;
        // #18500 double this to cancel the trailing borders.
        margin-left: (-$input-btn-border-width) * 2;
        // Because specificity
        @include hover-focus-active {
          z-index: 3;
        }
      }
    }

This fix reduces all .input-group-btn by 1px, I would also suggest removing the margin-right: (-$input-btn-border-width); to retain original width.

@vicary
Copy link
Author

vicary commented Dec 15, 2015

@cvrebert I could use your comment regarding the negative margin fix.

@cvrebert
Copy link
Collaborator

CC: @mdo

@vicary
Copy link
Author

vicary commented Dec 15, 2015

@cvrebert @mdo More on this, it is in fact Webkit who make this ugly.

Namely Chrome 47.0 and Safari 9.0.1, if you horizontally resize the browser you'll notice the double border only occurs when viewport width is with pixels in odd numbers, while even numbers will render normally without issue.

Tested in Firefox 40.0.3 it renders no double borders at all.

@cvrebert
Copy link
Collaborator

You might be describing https://code.google.com/p/chromium/issues/detail?id=534750 and its WebKit cousin.
So I'd probably give up on trying to fix double-borders in WebKit/Chrome, and just focus on getting the border overlap working in Firefox and having it make theoretical sense.
(I don't recall any reports of such a problem in IE, off the top of my head.)

@vicary
Copy link
Author

vicary commented Dec 16, 2015

@cvrebert If we're gonna let google fix that, the current commit is good enough to merge.

@mdo mdo merged commit 54fdb45 into twbs:v4-dev Feb 8, 2016
@mdo
Copy link
Member

mdo commented Feb 8, 2016

Merged and added docs example in 9c3ba54.

@mdo mdo added this to the v4.0.0-alpha.3 milestone Feb 8, 2016
@mdo mdo mentioned this pull request Feb 8, 2016
@vicary vicary deleted the multiple-input-group-addon branch February 11, 2016 06:28
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.

3 participants