Skip to content
GitLab
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
  • !11686

Enable specifying elements which can be focused

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/dana-shalev/allow-focusing-elements-which-are-not-modal-descendants into master Dec 03, 2013
  • Overview 0
  • Commits 2
  • Pipelines 0
  • Changes 1

Created by: dana-shalev

A modal dialog does not enable any element which is not a descendant of the dialog to recieve focus. This makes a lot of sense, of course but it also creates undesriable behavior in extreme cases where controls have elements which are direct descendants of the body element. For example, drop down elements are usually descendants of the body element and therefore does not behave nicely inside dialogs.

Related issues (drop down inside bootstrap modal dialog does not recieve focus):

  • Bootstrap: https://github.com/twbs/bootstrap/issues/6996
  • Select2: https://github.com/ivaynberg/select2/issues/600
  • ckEditor: http://dev.ckeditor.com/ticket/9934

I found many discussions on this issue and no final solution. However, I did find that the same problem existed in JQuery dialog and it solution (described here: https://github.com/ivaynberg/select2/issues/1246).

The idea is that the dialog exposes a method which enables the client to specify whether the element can recieve focus or not.

My change does exactly that: added an allowFocus method which is called from the enforceFocus method. If allowFocus returns true focus will not be enforced by the dialog.

The usage for enabling select2 dropdown to recieve focus is as follows:

$.fn.modal.Constructor.prototype.allowFocus = function (e) {
    return !!$(e.target).closest('.select2-drop');
};
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/dana-shalev/allow-focusing-elements-which-are-not-modal-descendants