Skip to content

Conversation

@snowystinger
Copy link
Member

@snowystinger snowystinger commented Dec 17, 2025

Closes

Go to a doc page like RSP's ActionButton, add an icon, get the share url for the example and paste it into a new window. It should render with no errors and the icon should be displayed.

✅ 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:

@rspbot
Copy link

rspbot commented Dec 17, 2025

yihuiliao
yihuiliao previously approved these changes Dec 17, 2025
import {TabLink} from './FileTabs';
import {useLocale} from 'react-aria';
// eslint-disable-next-line
import icons from '/packages/@react-spectrum/s2/s2wf-icons/*.svg';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem with this is that it breaks the code splitting, so now every icon will be loaded on every page even if the component doesn't have an icon picker...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, hmm is there a way to send it as a rsc?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise I guess I could send the svg directly

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could maybe load it dynamically if you export the icon map from the icon picker file?

const LazyIcon = lazy(() => import('./IconPicker')
  .then(({icons}) => ({default: ({icon}) => createElement(icons[icon])}))

essentially this creates a LazyIcon component that accepts an icon prop and gets that icon from the map.

<LazyIcon icon="whatever" />

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure yeah, could do that

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or even better put the LazyIcon component in the IconPicker file and lazily load that. Idk what I was thinking

@rspbot
Copy link

rspbot commented Dec 18, 2025

@LFDanLu LFDanLu added this pull request to the merge queue Dec 18, 2025
Merged via the queue into main with commit 9a1602e Dec 18, 2025
32 checks passed
@LFDanLu LFDanLu deleted the fix-url-copy-for-examples branch December 18, 2025 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants