From 496b0edbfd49ac12e69a9658234d2267e71c24b4 Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Mon, 11 Mar 2019 18:06:26 -0700 Subject: [PATCH 01/41] Cherry-pick from ysds --- scss/_button-group.scss | 12 ++++++++++-- scss/mixins/_buttons.scss | 8 ++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/scss/_button-group.scss b/scss/_button-group.scss index d7220029ad18..e1e63505e4d4 100644 --- a/scss/_button-group.scss +++ b/scss/_button-group.scss @@ -48,7 +48,8 @@ @include border-right-radius(0); } - > .btn:not(:first-child), + > .btn + .btn, + > .btn-group + .btn, > .btn-group:not(:first-child) > .btn { @include border-left-radius(0); } @@ -129,7 +130,8 @@ @include border-bottom-radius(0); } - > .btn:not(:first-child), + > .btn + .btn, + > .btn-group + .btn, > .btn-group:not(:first-child) > .btn { @include border-top-radius(0); } @@ -161,3 +163,9 @@ } } } + +.btn-group-input { + position: absolute; + z-index: -1; // Put the input behind the label so it doesn't overlay button + opacity: 0; +} diff --git a/scss/mixins/_buttons.scss b/scss/mixins/_buttons.scss index eee903f83ce5..1d5604a74e6c 100644 --- a/scss/mixins/_buttons.scss +++ b/scss/mixins/_buttons.scss @@ -16,7 +16,8 @@ } &:focus, - &.focus { + &.focus, + .btn-group-input:focus ~ & { // Avoid using mixin so we can pass custom focus shadow properly @if $enable-shadows { box-shadow: $btn-box-shadow, 0 0 0 $btn-focus-width rgba(mix(color-yiq($background), $border, 15%), .5); @@ -39,6 +40,7 @@ &:not(:disabled):not(.disabled):active, &:not(:disabled):not(.disabled).active, + .btn-group-input:checked ~ &, .show > &.dropdown-toggle { color: color-yiq($active-background); background-color: $active-background; @@ -69,7 +71,8 @@ } &:focus, - &.focus { + &.focus, + .btn-group-input:focus ~ & { box-shadow: 0 0 0 $btn-focus-width rgba($color, .5); } @@ -81,6 +84,7 @@ &:not(:disabled):not(.disabled):active, &:not(:disabled):not(.disabled).active, + .btn-group-input:checked ~ &, .show > &.dropdown-toggle { color: color-yiq($active-background); background-color: $active-background; From 63473a04f4d4dd762fafcbf6df0dec557549be12 Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Mon, 11 Mar 2019 18:30:46 -0700 Subject: [PATCH 02/41] Update docs to match new markup, drop JS --- js/src/button.js | 34 --------------------- scss/_button-group.scss | 18 ++--------- site/content/docs/4.3/components/buttons.md | 32 ++++++++++--------- 3 files changed, 20 insertions(+), 64 deletions(-) diff --git a/js/src/button.js b/js/src/button.js index 6453137e4ecb..65f52b19f166 100644 --- a/js/src/button.js +++ b/js/src/button.js @@ -71,40 +71,6 @@ class Button { Selector.DATA_TOGGLE ) - if (rootElement) { - const input = SelectorEngine.findOne(Selector.INPUT, this._element) - - if (input) { - if (input.type === 'radio') { - if (input.checked && - this._element.classList.contains(ClassName.ACTIVE)) { - triggerChangeEvent = false - } else { - const activeElement = SelectorEngine.findOne(Selector.ACTIVE, rootElement) - - if (activeElement) { - activeElement.classList.remove(ClassName.ACTIVE) - } - } - } - - if (triggerChangeEvent) { - if (input.hasAttribute('disabled') || - rootElement.hasAttribute('disabled') || - input.classList.contains('disabled') || - rootElement.classList.contains('disabled')) { - return - } - - input.checked = !this._element.classList.contains(ClassName.ACTIVE) - EventHandler.trigger(input, 'change') - } - - input.focus() - addAriaPressed = false - } - } - if (addAriaPressed) { this._element.setAttribute('aria-pressed', !this._element.classList.contains(ClassName.ACTIVE)) diff --git a/scss/_button-group.scss b/scss/_button-group.scss index e1e63505e4d4..26d37c176dea 100644 --- a/scss/_button-group.scss +++ b/scss/_button-group.scss @@ -150,22 +150,8 @@ // See https://github.com/twbs/bootstrap/pull/12794 and // https://github.com/twbs/bootstrap/pull/14559 for more information. -.btn-group-toggle { - > .btn, - > .btn-group > .btn { - margin-bottom: 0; // Override default `