diff --git a/cosmoz-data-nav.js b/cosmoz-data-nav.js index 6bb72c8..7dd6c3f 100644 --- a/cosmoz-data-nav.js +++ b/cosmoz-data-nav.js @@ -471,14 +471,16 @@ index = items.indexOf(this._previouslySelectedItem); // if not found, search by id - if (index === -1) { + if (index < 0) { const prevId = this._getItemId(this._previouslySelectedItem); index = items.findIndex(item => this._getItemId(item) === prevId); } // if still not found, remain on the selected index - if (index === -1) { - index = this.selected; + if (index < 0) { + index = this.selected < items.length + ? this.selected + : items.length - 1; } this._realignElements(index); } @@ -974,6 +976,8 @@ return idx; } } else if (isSelected) { + // make sure that the instance is visible (may be a re-aligned invisible instance) + element.__instance._showHideChildren(false); // resize is a expensive operation this._renderRan = this._notifyElementResize(); } diff --git a/test/.eslintrc.json b/test/.eslintrc.json index 0c6b7b9..1e871cd 100644 --- a/test/.eslintrc.json +++ b/test/.eslintrc.json @@ -3,6 +3,9 @@ "mocha": true }, "plugins": ["mocha"], + "parserOptions": { + "ecmaVersion": 8 + }, "globals": { "a11ySuite": false, "assert": false, diff --git a/test/bugs.html b/test/bugs.html new file mode 100644 index 0000000..f7e35f3 --- /dev/null +++ b/test/bugs.html @@ -0,0 +1,148 @@ + + + +
+