Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B bootstrap
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 263
    • Issues 263
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 114
    • Merge requests 114
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Bootstrap
  • bootstrap
  • Merge requests
  • !13612
An error occurred while fetching the assigned milestone of the selected merge_request.

Modals return focus to [data-target="modal"] on hidden

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/bassettsj/modal-focus-12364 into master 11 years ago
  • Overview 0
  • Commits 1
  • Pipelines 0
  • Changes 3

Created by: bassettsj

Resolves issue #12364 (closed)

  • small change in the data api to trigger focus on lauch element
  • attempt to write a test (HELP Needed!)
Compare
  • master (base)

and
  • latest version
    9b4ba760
    1 commit, 2 years ago

3 files
+ 27
- 0

    Preferences

    File browser
    Compare changes
dis‎t/js‎
bootst‎rap.js‎ +2 -0
j‎s‎
tests‎/unit‎
moda‎l.js‎ +23 -0
moda‎l.js‎ +2 -0
dist/js/bootstrap.js
+ 2
- 0
  • View file @ 9b4ba760


@@ -1076,6 +1076,8 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
Plugin.call($target, option, this)
$target.one('hide', function () {
$this.is(':visible') && $this.trigger('focus')
}).on('hidden.bs.modal', function() {
$this.trigger('focus')
})
})
js/tests/unit/modal.js
+ 23
- 0
  • View file @ 9b4ba760


@@ -201,4 +201,27 @@ $(function () {
div.remove()
})
test('should return focus to element trigger with [data-toggle="modal"]', function () {
stop()
$.support.transition = false
var div = $('<div id="modal-test" class="modal"></div>')
var button = $('<button type="button" id="button" data-target="#modal-test" data-toggle="modal">Show</button>')
div.appendTo('#qunit-fixture')
button.appendTo('#qunit-fixture')
div
.one('shown.bs.modal', function () {
div.bootstrapModal('hide')
})
.one('hidden.bs.modal', function () {
start()
ok(document.activeElement == button[0], 'returned focus to button')
})
button.click()
})
})
js/modal.js
+ 2
- 0
  • View file @ 9b4ba760


@@ -271,6 +271,8 @@
Plugin.call($target, option, this)
$target.one('hide', function () {
$this.is(':visible') && $this.trigger('focus')
}).on('hidden.bs.modal', function() {
$this.trigger('focus')
})
})
0 Assignees
None
Assign to
0 Reviewers
None
Request review from
Labels
0
None
0
None
    Assign labels
  • Manage project labels

Milestone
No milestone
None
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
1
1 participant
Administrator
Reference:
Source branch: github/fork/bassettsj/modal-focus-12364

Menu

Explore Projects Groups Snippets