-
Notifications
You must be signed in to change notification settings - Fork 3.6k
fix: preventing redirects from live preview #6858
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: preventing redirects from live preview #6858
Conversation
www/src/theme/Playground/Preview.tsx
Outdated
|
|
||
| const handleCustomRedirect = (e) => { | ||
| const target = e.target as HTMLElement; | ||
| if (target.closest('a[href]')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you try this?
if (e.target.tagName === 'A') {
e.preventDefault();
}
www/src/theme/Playground/Preview.tsx
Outdated
| ); | ||
|
|
||
|
|
||
| const handleCustomRedirect = (e) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you wrap this callback with a useEventCallback from @restart/hooks. Also add a type to e and remove the cast on line 60
|
Hi! @kyletsang, I've implemented the changes based on your suggestions. Could you please review and let me know if it looks good now? |
|
Thanks |
fixes: #6843
Hi! as discussed in PR #6852
to prevent the action on all anchors within code examples within the playground component, here is the revised solution.