Skip to content

Commit dac8eff

Browse files
Merge branch 'main' into gs-forms
2 parents afc89bf + 713d714 commit dac8eff

40 files changed

Lines changed: 573 additions & 1742 deletions

.github/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Guidelines for bug reports:
6969

7070
3. **Isolate the problem** — ideally create a [reduced test
7171
case](https://css-tricks.com/reduced-test-cases/) and a live example.
72-
[This JS Bin](https://jsbin.com/lolome/edit?html,output) is a helpful template.
72+
These [v4 CodePen](https://codepen.io/team/bootstrap/pen/yLabNQL) and [v5 CodePen](https://codepen.io/team/bootstrap/pen/qBamdLj) are helpful templates.
7373

7474

7575
A good bug report shouldn't leave others needing to chase you up for more

.github/workflows/issue-labeled.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ jobs:
1616
actions: "create-comment"
1717
token: ${{ secrets.GITHUB_TOKEN }}
1818
body: |
19-
Hello @${{ github.event.issue.user.login }}. Bug reports must include a **live demo** of the issue. Per our [contributing guidelines](https://github.com/twbs/bootstrap/blob/main/.github/CONTRIBUTING.md), please create a reduced test case on [CodePen](https://codepen.io/) or [JS Bin](https://jsbin.com/) and report back with your link, Bootstrap version, and specific browser and Operating System details.
19+
Hello @${{ github.event.issue.user.login }}. Bug reports must include a **live demo** of the issue. Per our [contributing guidelines](https://github.com/twbs/bootstrap/blob/main/.github/CONTRIBUTING.md), please create a reduced test case on [CodePen](https://codepen.io/) or [StackBlitz](https://stackblitz.com/) and report back with your link, Bootstrap version, and specific browser and Operating System details.

js/src/offcanvas.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class Offcanvas extends BaseComponent {
114114
this._element.classList.add(CLASS_NAME_SHOWING)
115115

116116
const completeCallBack = () => {
117-
if (!this._config.scroll) {
117+
if (!this._config.scroll || this._config.backdrop) {
118118
this._focustrap.activate()
119119
}
120120

js/src/tooltip.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,6 @@ class Tooltip extends BaseComponent {
344344
setContent(content) {
345345
this._newContent = content
346346
if (this._isShown()) {
347-
this.tip.remove()
348-
this.tip = null
349347
this._disposePopper()
350348
this.show()
351349
}
@@ -518,7 +516,7 @@ class Tooltip extends BaseComponent {
518516
return
519517
}
520518

521-
if (!this._element.getAttribute('aria-label') && !this._element.textContent) {
519+
if (!this._element.getAttribute('aria-label') && !this._element.textContent.trim()) {
522520
this._element.setAttribute('aria-label', title)
523521
}
524522

js/tests/unit/dom/selector-engine.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ describe('SelectorEngine', () => {
166166
'<span>lorem</span>',
167167
'<a>lorem</a>',
168168
'<button>lorem</button>',
169-
'<input />',
169+
'<input>',
170170
'<textarea></textarea>',
171171
'<select></select>',
172172
'<details>lorem</details>'

js/tests/unit/offcanvas.spec.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,8 @@ describe('Offcanvas', () => {
293293

294294
const offCanvasEl = fixtureEl.querySelector('.offcanvas')
295295
const offCanvas = new Offcanvas(offCanvasEl, {
296-
scroll: true
296+
scroll: true,
297+
backdrop: false
297298
})
298299

299300
const spy = spyOn(offCanvas._focustrap, 'activate').and.callThrough()
@@ -306,6 +307,27 @@ describe('Offcanvas', () => {
306307
offCanvas.show()
307308
})
308309
})
310+
311+
it('should trap focus if scroll is allowed OR backdrop is enabled', () => {
312+
return new Promise(resolve => {
313+
fixtureEl.innerHTML = '<div class="offcanvas"></div>'
314+
315+
const offCanvasEl = fixtureEl.querySelector('.offcanvas')
316+
const offCanvas = new Offcanvas(offCanvasEl, {
317+
scroll: true,
318+
backdrop: true
319+
})
320+
321+
const spy = spyOn(offCanvas._focustrap, 'activate').and.callThrough()
322+
323+
offCanvasEl.addEventListener('shown.bs.offcanvas', () => {
324+
expect(spy).toHaveBeenCalled()
325+
resolve()
326+
})
327+
328+
offCanvas.show()
329+
})
330+
})
309331
})
310332

311333
describe('toggle', () => {
@@ -603,7 +625,7 @@ describe('Offcanvas', () => {
603625
it('should not prevent event for input', () => {
604626
return new Promise(resolve => {
605627
fixtureEl.innerHTML = [
606-
'<input type="checkbox" data-bs-toggle="offcanvas" data-bs-target="#offcanvasdiv1" />',
628+
'<input type="checkbox" data-bs-toggle="offcanvas" data-bs-target="#offcanvasdiv1">',
607629
'<div id="offcanvasdiv1" class="offcanvas"></div>'
608630
].join('')
609631

js/tests/unit/tooltip.spec.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,6 +1358,25 @@ describe('Tooltip', () => {
13581358
})
13591359
})
13601360

1361+
it('should add the aria-label attribute when element text content is a whitespace string', () => {
1362+
return new Promise(resolve => {
1363+
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="A tooltip"><span> </span></a>'
1364+
1365+
const tooltipEl = fixtureEl.querySelector('a')
1366+
const tooltip = new Tooltip(tooltipEl)
1367+
1368+
tooltipEl.addEventListener('shown.bs.tooltip', () => {
1369+
const tooltipShown = document.querySelector('.tooltip')
1370+
1371+
expect(tooltipShown).not.toBeNull()
1372+
expect(tooltipEl.getAttribute('aria-label')).toEqual('A tooltip')
1373+
resolve()
1374+
})
1375+
1376+
tooltip.show()
1377+
})
1378+
})
1379+
13611380
it('should not add the aria-label attribute if the attribute already exists', () => {
13621381
return new Promise(resolve => {
13631382
fixtureEl.innerHTML = '<a href="#" rel="tooltip" aria-label="Different label" title="Another tooltip"></a>'

js/tests/unit/util/index.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,8 @@ describe('Util', () => {
425425
it('should return true if the element has disabled attribute', () => {
426426
fixtureEl.innerHTML = [
427427
'<div>',
428-
' <input id="input" disabled="disabled"/>',
429-
' <input id="input1" disabled="disabled"/>',
428+
' <input id="input" disabled="disabled">',
429+
' <input id="input1" disabled="disabled">',
430430
' <button id="button" disabled="true"></button>',
431431
' <button id="button1" disabled="disabled"></button>',
432432
' <button id="button2" disabled></button>',
@@ -460,7 +460,7 @@ describe('Util', () => {
460460
it('should return true if the element has class "disabled" but disabled attribute is false', () => {
461461
fixtureEl.innerHTML = [
462462
'<div>',
463-
' <input id="input" class="disabled" disabled="false"/>',
463+
' <input id="input" class="disabled" disabled="false">',
464464
'</div>'
465465
].join('')
466466

0 commit comments

Comments
 (0)