Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tmeasday committed Jul 15, 2022
1 parent 4bb392e commit 0121716
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
7 changes: 5 additions & 2 deletions lib/blocks/src/blocks/mdx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ interface AnchorMdxProps {

export const AnchorMdx: FC<AnchorMdxProps> = (props) => {
const { href, target, children, ...rest } = props;
const context = useContext(DocsContext);

if (href) {
// Enable scrolling for in-page anchors.
Expand All @@ -103,7 +104,7 @@ export const AnchorMdx: FC<AnchorMdxProps> = (props) => {
event.preventDefault();
// use the A element's href, which has been modified for
// local paths without a `?path=` query param prefix
navigate(event.currentTarget.getAttribute('href'));
navigate(context, event.currentTarget.getAttribute('href'));
}}
target={target}
{...rest}
Expand Down Expand Up @@ -156,6 +157,8 @@ const HeaderWithOcticonAnchor: FC<HeaderWithOcticonAnchorProps> = ({
children,
...rest
}) => {
const context = useContext(DocsContext);

// @ts-ignore
const OcticonHeader = OcticonHeaders[as];
const hash = `#${id}`;
Expand All @@ -170,7 +173,7 @@ const HeaderWithOcticonAnchor: FC<HeaderWithOcticonAnchorProps> = ({
onClick={(event: SyntheticEvent) => {
const element = document.getElementById(id);
if (element) {
navigate(hash);
navigate(context, hash);
}
}}
>
Expand Down
2 changes: 1 addition & 1 deletion lib/preview-web/src/Preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class Preview<TFramework extends AnyFramework> {

previewEntryError?: Error;

constructor(private channel: Channel = addons.getChannel()) {
constructor(protected channel: Channel = addons.getChannel()) {
if (global.FEATURES?.storyStoreV7 && addons.hasServerChannel()) {
this.serverChannel = addons.getServerChannel();
}
Expand Down
10 changes: 2 additions & 8 deletions lib/preview-web/src/docs-context/DocsContext.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import {
AnyFramework,
ComponentTitle,
StoryContextForLoaders,
StoryId,
StoryName,
} from '@storybook/csf';
import { CSFFile, ModuleExport, ModuleExports, Story, StoryStore } from '@storybook/store';
import type { AnyFramework, StoryContextForLoaders, StoryId, StoryName } from '@storybook/csf';
import type { CSFFile, ModuleExport, ModuleExports, Story, StoryStore } from '@storybook/store';
import type { Channel } from '@storybook/channels';

import { DocsContextProps } from './DocsContextProps';
Expand Down

0 comments on commit 0121716

Please sign in to comment.