Skip to content

Commit

Permalink
feature: focusId must be a non-empty string (if specified)
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniele Lubrano committed Feb 9, 2022
1 parent c0b0794 commit 0fc85db
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/focus-node.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,9 @@ export function FocusNode(
const nonStringFocusId =
typeof focusId !== 'string' && focusId !== undefined;
const reservedFocusId = focusId === 'root';
const invalidNodeId = nonStringFocusId || reservedFocusId;
const emptyStringNode = focusId + '' === '';
const invalidNodeId =
nonStringFocusId || reservedFocusId || emptyStringNode;

if (process.env.NODE_ENV !== 'production') {
if (reservedFocusId) {
Expand All @@ -192,9 +194,9 @@ export function FocusNode(
);
}

if (nonStringFocusId) {
if (nonStringFocusId || emptyStringNode) {
warning(
'A focus node with an invalid focus ID was created: "root". This is a reserved ID, so it has been ' +
'A focus node with an invalid (non-string or empty string) focus ID was created. This is a not supported ID type (expected non-empty string), so it has been ' +
'ignored. Please choose another ID if you wish to specify an ID.',
'INVALID_FOCUS_ID_PASSED'
);
Expand Down

0 comments on commit 0fc85db

Please sign in to comment.