fix: Cannot read properties of undefined (reading 'matches') (#25280)

This commit is contained in:
Pawan Kumar 2023-07-17 16:57:27 +05:30 committed by GitHub
parent 101d572482
commit 82d7bccffa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 1 deletions

View File

@ -17,7 +17,7 @@ export function handleTab(event: KeyboardEvent) {
const currentWidget = currentNode.closest(WIDGET_SELECTOR) as HTMLElement;
switch (true) {
// when the current node is a widget, we want to do tabbing in regular way
// when the current node is one of these widget, we want to do tabbing in regular way
// the elements will be in proper order in dom for thes widgets
case currentWidget && currentWidget.matches(JSONFORM_WIDGET):
case currentWidget && currentWidget.matches(CHECKBOXGROUP_WIDGET):

View File

@ -0,0 +1,7 @@
import { getNextTabbableDescendant } from "./tabbable";
describe("getNextTabbableDescendant", () => {
it("should return undefined if no descendants are passed", () => {
expect(getNextTabbableDescendant([])).toBeUndefined();
});
});

View File

@ -115,6 +115,8 @@ export function getNextTabbableDescendant(
) {
const nextTabbableDescendant = descendants[0];
if (!nextTabbableDescendant) return;
// if nextTabbableDescendant is a container,
if (nextTabbableDescendant.matches(CONTAINER_SELECTOR)) {
const tabbableDescendants = getChildrenWidgetsOfNode(