Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit 8e5ad95

Browse files
committed
Fix #5310 (Editor HTML menus are broken).
Override the implementation of the jquery focus() to prevent HTML menus (class "dropdown-toggle") grabbing the focus. Bootstrap's dropdown implementation exlicitly calls focus() which causes currently active CM instance to lose focus. As the result, when the command is executed, it cannot get ahold of the current editor instance.
1 parent d233dbd commit 8e5ad95

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/brackets.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,16 @@ define(function (require, exports, module) {
273273
// Enable/Disable HTML Menus
274274
if (brackets.nativeMenus) {
275275
$("body").addClass("has-appshell-menus");
276+
} else {
277+
// Prevent the menu item to grab the focus -- override focus implementation
278+
(function () {
279+
var defaultFocus = $.fn.focus;
280+
$.fn.focus = function () {
281+
if (!this.hasClass("dropdown-toggle")) {
282+
defaultFocus.apply(this, arguments);
283+
}
284+
};
285+
}());
276286
}
277287

278288
// Localize MainViewHTML and inject into <BODY> tag

0 commit comments

Comments
 (0)