From 2a09783d2d85ce6e879400bbeeac17f035e2761e Mon Sep 17 00:00:00 2001 From: joe-allen-89 <85872286+joe-allen-89@users.noreply.github.com> Date: Mon, 30 Oct 2023 16:51:46 +0000 Subject: [PATCH] Fix: Exclude hidden items from items count ARIA (fixes #164) (#170) * Fix: Exclude hidden items from items count ARIA * Fix: BoxMenuGroupView updated to exclude hidden children. --- js/BoxMenuGroupView.js | 4 +++- js/BoxMenuView.js | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/js/BoxMenuGroupView.js b/js/BoxMenuGroupView.js index 2230d29..5bd6937 100644 --- a/js/BoxMenuGroupView.js +++ b/js/BoxMenuGroupView.js @@ -15,7 +15,9 @@ class BoxMenuGroupView extends MenuItemView { } updateItemCount() { - const models = this.model.getChildren().models; + const models = this.model.getChildren().where({ + _isHidden: false + }); const totalChildren = models.length; models.forEach(model => model.set('_totalChild', totalChildren)); } diff --git a/js/BoxMenuView.js b/js/BoxMenuView.js index 6692c9c..e98e7e5 100644 --- a/js/BoxMenuView.js +++ b/js/BoxMenuView.js @@ -23,6 +23,10 @@ class BoxMenuView extends MenuView { addChildren() { let nthChild = 0; const models = this.model.getChildren().models; + const totalChild = this.model.getChildren().where({ + _isHidden: false + }).length; + const childViews = []; models.forEach(model => { if (!model.get('_isAvailable')) return; @@ -35,7 +39,7 @@ class BoxMenuView extends MenuView { nthChild++; model.set({ _nthChild: nthChild, - _totalChild: models.length + _totalChild: totalChild }); const ChildView = (model.get('_type') === 'menu' && model.get('_boxMenu') && model.get('_boxMenu')._renderAsGroup) ?