editor: insert new champs after the last fully visible champ
Before, when the "Add new champ" button was clicked, the new champ was inserted after the **first** fully visible champ. That was most of the time unexpected. The correct behavior would be to insert the new champ after the **last** fully visible champ. That's what this commit does. Now the "Add new champ" behavior feels much less confusing.
This commit is contained in:
parent
91002865b0
commit
fc8a0d46ff
1 changed files with 5 additions and 3 deletions
|
@ -219,7 +219,7 @@ function getUpdateHandler(typeDeChamp, { queue, flash }) {
|
|||
}
|
||||
|
||||
function findItemToInsertAfter() {
|
||||
const target = getFirstTarget();
|
||||
const target = getLastVisibleTypeDeChamp();
|
||||
|
||||
return {
|
||||
target,
|
||||
|
@ -227,8 +227,10 @@ function findItemToInsertAfter() {
|
|||
};
|
||||
}
|
||||
|
||||
function getFirstTarget() {
|
||||
const [target] = document.querySelectorAll('[data-in-view]');
|
||||
function getLastVisibleTypeDeChamp() {
|
||||
const typeDeChamps = document.querySelectorAll('[data-in-view]');
|
||||
const target = typeDeChamps[typeDeChamps.length - 1];
|
||||
|
||||
if (target) {
|
||||
const parentTarget = target.closest('[data-repetition]');
|
||||
if (parentTarget) {
|
||||
|
|
Loading…
Reference in a new issue