Skip to content

Commit

Permalink
Fix tooltip offset when using Bootstrap > 5.3 (#2119)
Browse files Browse the repository at this point in the history
This was caused by this upstream change: twbs/bootstrap@d533e6f

The fix causes tooltips to be slightly positioned wrong for Bootstrap >= 5 and < 5.3. We decided to accept that trade-off. React Bootstrap has done the same: react-bootstrap/react-bootstrap#6622
  • Loading branch information
SanderKnauff committed Apr 4, 2024
1 parent c0817f9 commit 4a05c26
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions ember-bootstrap/addon/components/bs-tooltip/element.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ import { getOwnConfig, macroCondition } from '@embroider/macros';
export default class TooltipElement extends ContextualHelpElement {
arrowClass = macroCondition(getOwnConfig().isBS4) ? 'arrow' : 'tooltip-arrow';
placementClassPrefix = 'bs-tooltip-';
offset = [0, 6];
}
8 changes: 4 additions & 4 deletions test-app/tests/integration/components/bs-tooltip-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ module('Integration | Component | bs-tooltip', function (hooks) {
setupForPositioning();

await triggerEvent('#target', 'mouseenter');
assertPositioning(assert);
assertPositioning(assert, '.tooltip', 6);
});

test('should place tooltip on top of element if already visible', async function (assert) {
Expand All @@ -410,7 +410,7 @@ module('Integration | Component | bs-tooltip', function (hooks) {
setupForPositioning();
this.set('visible', true);
await settled();
assertPositioning(assert);
assertPositioning(assert, '.tooltip', 6);
});

test('should place tooltip on top of element if visible is set to true', async function (assert) {
Expand All @@ -433,7 +433,7 @@ module('Integration | Component | bs-tooltip', function (hooks) {

this.set('visible', true);
await settled();
assertPositioning(assert);
assertPositioning(assert, '.tooltip', 6);
});

test("should show tooltip if leave event hasn't occurred before delay expires", async function (assert) {
Expand Down Expand Up @@ -630,7 +630,7 @@ module('Integration | Component | bs-tooltip', function (hooks) {
await delay(50);

assert.dom('.tooltip').hasClass(tooltipPositionClass('top'));
assertPositioning(assert);
assertPositioning(assert, '.tooltip', 6);
});

test('it yields close action', async function (assert) {
Expand Down

0 comments on commit 4a05c26

Please sign in to comment.