mirror of
https://github.com/evennia/evennia.git
synced 2026-03-31 13:07:16 +02:00
fix: multiple inputs now retain focus correctly
This commit is contained in:
parent
1b67bc1ea1
commit
cbb40d94f6
3 changed files with 31 additions and 9 deletions
|
|
@ -47,7 +47,7 @@ let defaultInPlugin = (function () {
|
|||
|
||||
// enter key by itself should toggle focus
|
||||
if( inputfield.length < 1 ) {
|
||||
inputfield = $(".inputfield:last");
|
||||
inputfield = $(".inputfield.focused");
|
||||
inputfield.focus();
|
||||
if( inputfield.length < 1 ) { // non-goldenlayout backwards compatibility
|
||||
$("#inputfield").focus();
|
||||
|
|
@ -64,9 +64,9 @@ let defaultInPlugin = (function () {
|
|||
if( focusOnKeydown ) {
|
||||
// is an inputfield actually focused?
|
||||
if( inputfield.length < 1 ) {
|
||||
// Nope, focus the last .inputfield found in the DOM (or #inputfield)
|
||||
// :last only matters if multi-input plugins are in use
|
||||
inputfield = $(".inputfield:last");
|
||||
// Nope, focus the most recently used input field (or #inputfield)
|
||||
// .focused only matters if multi-input plugins are in use
|
||||
inputfield = $(".inputfield.focused");
|
||||
inputfield.focus();
|
||||
if( inputfield.length < 1 ) { // non-goldenlayout backwards compatibility
|
||||
$("#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 typelist = document.getElementById("typelist");
|
||||
let updatelist = document.getElementById("updatelist");
|
||||
|
|
@ -268,7 +286,6 @@ let goldenlayout = (function () {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Save the GoldenLayout state to localstorage whenever it changes.
|
||||
var onStateChanged = function () {
|
||||
|
|
@ -344,7 +361,7 @@ let goldenlayout = (function () {
|
|||
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) {
|
||||
//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
|
||||
splitControl.click( tab, function (evnt) {
|
||||
|
|
@ -362,7 +381,7 @@ let goldenlayout = (function () {
|
|||
// Add the typeDropdown to the header
|
||||
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" />
|
||||
|
||||
<!-- 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 -->
|
||||
{% block jquery_import %}
|
||||
<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