Skip to content

fix: breadcrumbs href undefined causing an empty string#10286

Open
snowystinger wants to merge 1 commit into
mainfrom
fix-breadcrumbs-chromatic
Open

fix: breadcrumbs href undefined causing an empty string#10286
snowystinger wants to merge 1 commit into
mainfrom
fix-breadcrumbs-chromatic

Conversation

@snowystinger

Copy link
Copy Markdown
Member

Closes

Noticed while debugging the Breadcrumbs chromatic story snapshot change. If you are on main and run yarn chromatic, then go to the S2 Breadcrumb story, after it loads, it'll error with
"Error: An empty string ("") was passed to the href attribute. To fix this, either do not render the element at all or pass null to href instead of an empty string."

This is because open link checks if a key in in the props but doesn't check if it's undefined value. In React, undefined in the props object is considered the same as the key not being present. So I've updated our check to match React behaviour.
The reason that it was an issue is because of this change https://github.com/adobe/react-spectrum/pull/7032/changes which now always calls useHref. However, it would return an empty string, and that was what was used.

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

🧢 Your Project:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants