Skip to content

Commit 8aca49e

Browse files
blunteshwarWestbrook
authored andcommitted
fix(tags): suggested changes done
1 parent f97c7a7 commit 8aca49e

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

tools/reactive-controllers/src/FocusGroup.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -154,19 +154,16 @@ export class FocusGroupController<T extends HTMLElement>
154154
this._listenerScope
155155
);
156156
}
157-
/* In handleItemMutation() method the first if condition is checking if the element is not focused or if the element's children's length is not decreasing then it means no element has been deleted and we must return.
158-
Then we are checking if the deleted element was the focused one before the deletion if so then we need to proceed else we casn return;
159-
*/
157+
/* In handleItemMutation() method the first if condition is checking if the element is not focused or if the element's children's length is not decreasing then it means no element has been deleted and we must return.
158+
Then we are checking if the deleted element was the focused one before the deletion if so then we need to proceed else we casn return;
159+
*/
160160
handleItemMutation(): void {
161-
if (
162-
this._currentIndex == -1 ||
163-
this.elements.length <= this._elements.length
164-
)
165-
return;
166-
this.clearElementCache();
161+
if (this._currentIndex == -1) return;
162+
const lengthOfElementsBeforeMutation = this.elements.length;
167163
const focusedElement = this.elements[this.currentIndex];
164+
this.clearElementCache();
165+
if (lengthOfElementsBeforeMutation <= this.elements.length) return;
168166
if (this.elements.includes(focusedElement)) return;
169-
170167
const moveToNextElement = this.currentIndex !== this.elements.length;
171168
const diff = moveToNextElement ? 1 : -1;
172169
if (moveToNextElement) {

0 commit comments

Comments
 (0)