Skip to content

Commit

Permalink
fix: playground button opens a new tab (#1932)
Browse files Browse the repository at this point in the history
* fix: playground button opens a new tab

* refactor: remove useRouter
  • Loading branch information
gui-santos authored Mar 4, 2022
1 parent 6733a73 commit 12f9492
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions packages/website/components/LiveEditor/ComponentSource.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { ExternalLinkIcon } from '@contentful/f36-icons';
import { Flex } from '@contentful/f36-core';
import { theme } from './theme';
import { formatSourceCode } from './utils';
import { useRouter } from 'next/router';
import * as coder from '../../utils/coder';
import FocusLock from 'react-focus-lock';
import {
Expand Down Expand Up @@ -143,7 +142,6 @@ export function ComponentSource({
file?: string;
}) {
const [showSource, setShowSource] = useState(true);
const router = useRouter();

const handleToggle = () => {
setShowSource((prevState) => !prevState);
Expand Down Expand Up @@ -206,15 +204,12 @@ export function ComponentSource({
/>
{isExampleFromFile && (
<Button
as="a"
className={styles.playgroundButton}
endIcon={<ExternalLinkIcon />}
size="small"
onClick={() => {
const href = `/playground?code=${coder.encode(
children,
)}`;
router.push(href, href);
}}
href={`/playground?code=${coder.encode(children)}`}
target="_blank"
>
Open in Playground
</Button>
Expand Down

1 comment on commit 12f9492

@vercel
Copy link

@vercel vercel bot commented on 12f9492 Mar 4, 2022

Choose a reason for hiding this comment

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

Please sign in to comment.