fix: multiple inputs now retain focus correctly
This commit is contained in:
parent
6e45ac0cb1
commit
17791e71b7
3 changed files with 31 additions and 9 deletions
|
|
@ -47,7 +47,7 @@ let defaultInPlugin = (function () {
|
||||||
|
|
||||||
// enter key by itself should toggle focus
|
// enter key by itself should toggle focus
|
||||||
if( inputfield.length < 1 ) {
|
if( inputfield.length < 1 ) {
|
||||||
inputfield = $(".inputfield:last");
|
inputfield = $(".inputfield.focused");
|
||||||
inputfield.focus();
|
inputfield.focus();
|
||||||
if( inputfield.length < 1 ) { // non-goldenlayout backwards compatibility
|
if( inputfield.length < 1 ) { // non-goldenlayout backwards compatibility
|
||||||
$("#inputfield").focus();
|
$("#inputfield").focus();
|
||||||
|
|
@ -64,9 +64,9 @@ let defaultInPlugin = (function () {
|
||||||
if( focusOnKeydown ) {
|
if( focusOnKeydown ) {
|
||||||
// is an inputfield actually focused?
|
// is an inputfield actually focused?
|
||||||
if( inputfield.length < 1 ) {
|
if( inputfield.length < 1 ) {
|
||||||
// Nope, focus the last .inputfield found in the DOM (or #inputfield)
|
// Nope, focus the most recently used input field (or #inputfield)
|
||||||
// :last only matters if multi-input plugins are in use
|
// .focused only matters if multi-input plugins are in use
|
||||||
inputfield = $(".inputfield:last");
|
inputfield = $(".inputfield.focused");
|
||||||
inputfield.focus();
|
inputfield.focus();
|
||||||
if( inputfield.length < 1 ) { // non-goldenlayout backwards compatibility
|
if( inputfield.length < 1 ) { // non-goldenlayout backwards compatibility
|
||||||
$("#inputfield").focus();
|
$("#inputfield").focus();
|
||||||
|
|
|
||||||
|
|
@ -247,10 +247,28 @@ let goldenlayout = (function () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// ensure only one handler is set up on the parent with _.once
|
||||||
|
var registerInputTabChangeHandler = _.once(function (tab) {
|
||||||
|
tab.header.parent.on( "activeContentItemChanged", onActiveInputTabChange );
|
||||||
|
});
|
||||||
|
|
||||||
//
|
//
|
||||||
|
// Handle when the active input tab changes
|
||||||
|
var onActiveInputTabChange = function (tab) {
|
||||||
|
$('.inputfield').removeClass('focused');
|
||||||
|
$('.inputfield', tab.tab.contentItem.element).addClass('focused');
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
var onActiveTabChange = function (tab) {
|
// ensure only one handler is set up on the parent with _.once
|
||||||
|
var registerMainTabChangeHandler = _.once(function (tab) {
|
||||||
|
tab.header.parent.on( "activeContentItemChanged", onActiveMainTabChange );
|
||||||
|
});
|
||||||
|
|
||||||
|
//
|
||||||
|
// Handle when the active main tab changes
|
||||||
|
var onActiveMainTabChange = function (tab) {
|
||||||
let renamebox = document.getElementById("renamebox");
|
let renamebox = document.getElementById("renamebox");
|
||||||
let typelist = document.getElementById("typelist");
|
let typelist = document.getElementById("typelist");
|
||||||
let updatelist = document.getElementById("updatelist");
|
let updatelist = document.getElementById("updatelist");
|
||||||
|
|
@ -268,7 +286,6 @@ let goldenlayout = (function () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Save the GoldenLayout state to localstorage whenever it changes.
|
// Save the GoldenLayout state to localstorage whenever it changes.
|
||||||
var onStateChanged = function () {
|
var onStateChanged = function () {
|
||||||
|
|
@ -344,7 +361,7 @@ let goldenlayout = (function () {
|
||||||
tab.element.prepend( $("#optionsbutton").clone(true).addClass("lm_title") );
|
tab.element.prepend( $("#optionsbutton").clone(true).addClass("lm_title") );
|
||||||
}
|
}
|
||||||
|
|
||||||
tab.header.parent.on( "activeContentItemChanged", onActiveTabChange );
|
registerMainTabChangeHandler(tab);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -352,7 +369,9 @@ let goldenlayout = (function () {
|
||||||
//
|
//
|
||||||
var onInputCreate = function (tab) {
|
var onInputCreate = function (tab) {
|
||||||
//HTML for the typeDropdown
|
//HTML for the typeDropdown
|
||||||
let splitControl = $("<span class='lm_title' style='font-size: 1.5em;width: 1em;'>+</span>");
|
let splitControl = $(
|
||||||
|
"<span class='lm_title' style='font-size: 1.5em;width: 1em;'>+</span>"
|
||||||
|
);
|
||||||
|
|
||||||
// track adding a new tab
|
// track adding a new tab
|
||||||
splitControl.click( tab, function (evnt) {
|
splitControl.click( tab, function (evnt) {
|
||||||
|
|
@ -362,7 +381,7 @@ let goldenlayout = (function () {
|
||||||
// Add the typeDropdown to the header
|
// Add the typeDropdown to the header
|
||||||
tab.element.append( splitControl );
|
tab.element.append( splitControl );
|
||||||
|
|
||||||
tab.header.parent.on( "activeContentItemChanged", onActiveTabChange );
|
registerInputTabChangeHandler(tab);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,9 @@ JQuery available.
|
||||||
|
|
||||||
<link rel="icon" type="image/x-icon" href="/static/website/images/evennia_logo.png" />
|
<link rel="icon" type="image/x-icon" href="/static/website/images/evennia_logo.png" />
|
||||||
|
|
||||||
|
<!-- Lodash -->
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js" integrity="sha256-qXBd/EfAdjOA2FGrGAG+b3YBn2tn5A6bhz+LSgYD96k=" crossorigin="anonymous"></script>
|
||||||
|
|
||||||
<!-- Import JQuery and warn if there is a problem -->
|
<!-- Import JQuery and warn if there is a problem -->
|
||||||
{% block jquery_import %}
|
{% block jquery_import %}
|
||||||
<script src="https://code.jquery.com/jquery-3.2.1.min.js" type="text/javascript" charset="utf-8"></script>
|
<script src="https://code.jquery.com/jquery-3.2.1.min.js" type="text/javascript" charset="utf-8"></script>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue