Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate deprecated $().focus() calls #1160

Merged
merged 2 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion demo/sample-ext-filter.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
}
$("button#btnResetSearch").attr("disabled", false);
$("span#matches").text("(" + n + " matches)");
}).focus();
}).trigger("focus");

$("button#btnResetSearch").click(function(e){
$("input[name=search]").val("");
Expand Down
2 changes: 1 addition & 1 deletion demo/taxonomy-browser/taxonomy-browser-itis.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@
$("#btnResetSearch").attr("disabled", query.length === 0);
$("#btnSearch").attr("disabled", query.length < 2);
})
.focus();
.trigger("focus");

$("#btnResetSearch").click(function (e) {
$("#searchResultPane").collapse("hide");
Expand Down
2 changes: 1 addition & 1 deletion demo/taxonomy-browser/taxonomy-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@
$("#btnResetSearch").attr("disabled", query.length === 0);
$("#btnSearch").attr("disabled", query.length < 2);
})
.focus();
.trigger("focus");

$("#btnResetSearch").click(function (e) {
$("#searchResultPane").collapse("hide");
Expand Down
6 changes: 3 additions & 3 deletions src/jquery.fancytree.ariagrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,10 @@
$input = $td.find(":input:enabled,a");
this.debug("Focus input", $input);
if ($input.length) {
$input.focus();
$input.trigger("focus");
setActiveDescendant(this, $input);
} else {
$td.attr("tabindex", "-1").focus();
$td.attr("tabindex", "-1").trigger("focus");
setActiveDescendant(this, $td);
}
} else {
Expand Down Expand Up @@ -610,7 +610,7 @@
case "esc":
if ($activeTd && !tree.forceNavMode) {
// Switch from cell-edit-mode to cell-nav-mode
// $target.closest( "td" ).focus();
// $target.closest( "td" ).trigger("focus");
tree.forceNavMode = true;
tree.debug("Enter cell-nav-mode");
tree.$container.toggleClass(
Expand Down
6 changes: 4 additions & 2 deletions src/jquery.fancytree.dnd.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,13 +400,15 @@
"Re-enable focus that was prevented by jQuery UI draggable."
);
// node.setFocus();
// $(node.span).closest(":tabbable").focus();
// $(node.span).closest(":tabbable").trigger("focus");
// $(event.target).trigger("focus");
// $(event.target).closest(":tabbable").trigger("focus");
}
setTimeout(function () {
// #300
$(event.target).closest(":tabbable").focus();
$(event.target)
.closest(":tabbable")
.trigger("focus");
}, 10);
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/jquery.fancytree.edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@

// Focus <input> and bind keyboard handler
$input
.focus()
.trigger("focus")
.change(function (event) {
$input.addClass("fancytree-edit-dirty");
})
Expand Down
2 changes: 1 addition & 1 deletion src/jquery.fancytree.fixed.js
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@

// treeSetFocus: function(ctx, flag) {
//// alert("treeSetFocus" + ctx.tree.$container);
// ctx.tree.$container.focus();
// ctx.tree.$container.trigger("focus");
// $.ui.fancytree.focusTree = ctx.tree;
// }
});
Expand Down
8 changes: 5 additions & 3 deletions src/jquery.fancytree.gridnav.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@
if (flag) {
if (ctx.options.titlesTabbable) {
if (!triggeredByInput) {
$(node.span).find("span.fancytree-title").focus();
$(node.span)
.find("span.fancytree-title")
.trigger("focus");
node.setFocus();
}
// If one node is tabbable, the container no longer needs to be
Expand All @@ -177,7 +179,7 @@
// Set focus to input sub input (if node was clicked, but not
// when TAB was pressed )
$outer = $(node.tr || node.span);
$outer.find(":input:enabled").first().focus();
$outer.find(":input:enabled").first().trigger("focus");
}
}
},
Expand All @@ -202,7 +204,7 @@
$td = findNeighbourTd($target, event.which);
if ($td && $td.length) {
// ctx.node.debug("ignore keydown in input", event.which, handleKeys);
$td.find(":input:enabled,a").focus();
$td.find(":input:enabled,a").trigger("focus");
// Prevent Fancytree default navigation
return false;
}
Expand Down
12 changes: 7 additions & 5 deletions src/jquery.fancytree.js
Original file line number Diff line number Diff line change
Expand Up @@ -5690,7 +5690,9 @@
if (opts.titlesTabbable) {
if (!isInput) {
// #621
$(node.span).find(".fancytree-title").focus();
$(node.span)
.find(".fancytree-title")
.trigger("focus");
}
}
if (opts.aria) {
Expand All @@ -5703,7 +5705,7 @@
);
// "ftal_" + opts.idPrefix + node.key);
}
// $(node.span).find(".fancytree-title").focus();
// $(node.span).find(".fancytree-title").trigger("focus");
this._triggerNodeEvent("focus", ctx);

// determine if we have focus on or inside tree container
Expand All @@ -5713,10 +5715,10 @@

if (!hasFancytreeFocus) {
// We cannot set KB focus to a node, so use the tree container
// #563, #570: IE scrolls on every call to .focus(), if the container
// #563, #570: IE scrolls on every call to .trigger("focus"), if the container
// is partially outside the viewport. So do it only, when absolutely
// necessary.
$(tree.$container).focus();
$(tree.$container).trigger("focus");
}

// if( opts.autoActivate ){
Expand Down Expand Up @@ -6164,7 +6166,7 @@
// Node also looses focus if widget blurs
this.focusNode.setFocus(false);
} else if (flag && (!callOpts || !callOpts.calledByNode)) {
$(this.$container).focus();
$(this.$container).trigger("focus");
}
this.$container.toggleClass("fancytree-treefocus", flag);
this._triggerTreeEvent(flag ? "focusTree" : "blurTree");
Expand Down
2 changes: 1 addition & 1 deletion src/jquery.fancytree.menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
of: ctx.originalEvent,
collision: "fit",
})
.focus();
.trigger("focus");

opts.menu.open.call(tree, ctx.originalEvent, data);
},
Expand Down
6 changes: 4 additions & 2 deletions src/jquery.fancytree.persist.js
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,11 @@
if (node) {
// node.debug("persist: set focus", cookie);
if (tree.options.titlesTabbable) {
$(node.span).find(".fancytree-title").focus();
$(node.span)
.find(".fancytree-title")
.trigger("focus");
} else {
$(tree.$container).focus();
$(tree.$container).trigger("focus");
}
// node.setFocus();
}
Expand Down
2 changes: 1 addition & 1 deletion src/jquery.fancytree.table.js
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@
/*,
treeSetFocus: function(ctx, flag) {
// alert("treeSetFocus" + ctx.tree.$container);
ctx.tree.$container.focus();
ctx.tree.$container.trigger("focus");
$.ui.fancytree.focusTree = ctx.tree;
}*/
});
Expand Down
2 changes: 1 addition & 1 deletion test/test-ext-keyboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
var node = data.node;

// Set focus to embedded input
$("span.fancytree-title :input", node.span).focus();
$("span.fancytree-title :input", node.span).trigger("focus");
},
keydown: function(event, data){
var KC = $.ui.keyCode;
Expand Down
2 changes: 1 addition & 1 deletion test/test-ext-table.html
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
var n = tree.filterNodes(match);
$("#btnResetSearch").attr("disabled", false);
$("span#matches").text("(" + n + " matches)");
}).focus();
}).trigger("focus");

$("#btnResetSearch").click(function(e){
$("input[name=search]").val("");
Expand Down
2 changes: 1 addition & 1 deletion test/text-ext-filter.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
$('button#btnResetSearch').attr('disabled', false);
$('span#matches').text('(' + n + ' matches)');
})
.focus();
.trigger("focus");

$('fieldset input:checkbox').change(function(e) {
var id = $(this).attr('id'),
Expand Down
Loading