Skip to content

Commit

Permalink
Remove unecessary anchor and add preventDefault when custom skipToCon…
Browse files Browse the repository at this point in the history
…tentTarget is clicked
  • Loading branch information
henryyi committed Jan 27, 2021
1 parent 14ed8a7 commit 68d975d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/components/Frame/Frame.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {PureComponent, createRef} from 'react';
import React, {PureComponent, createRef, MouseEvent} from 'react';
import {MobileCancelMajor} from '@shopify/polaris-icons';
import {durationSlow} from '@shopify/polaris-tokens';
import {CSSTransition} from 'react-transition-group';
Expand Down Expand Up @@ -64,7 +64,6 @@ interface State {
const GLOBAL_RIBBON_CUSTOM_PROPERTY = '--global-ribbon-height';

const APP_FRAME_MAIN = 'AppFrameMain';

const APP_FRAME_NAV = 'AppFrameNav';
const APP_FRAME_TOP_BAR = 'AppFrameTopBar';
const APP_FRAME_LOADING_BAR = 'AppFrameLoadingBar';
Expand All @@ -81,8 +80,6 @@ class FrameInner extends PureComponent<CombinedProps, State> {
private contextualSaveBar: ContextualSaveBarProps | null = null;
private globalRibbonContainer: HTMLDivElement | null = null;
private navigationNode = createRef<HTMLDivElement>();
private skipToMainContentTargetNode =
this.props.skipToContentTarget || createRef<HTMLAnchorElement>();

componentDidMount() {
this.handleResize();
Expand Down Expand Up @@ -377,9 +374,12 @@ class FrameInner extends PureComponent<CombinedProps, State> {
this.setState({skipFocused: false});
};

private handleClick = () => {
this.skipToMainContentTargetNode.current &&
this.skipToMainContentTargetNode.current.focus();
private handleClick = (event: MouseEvent<HTMLAnchorElement>) => {
const {skipToContentTarget} = this.props;
if (skipToContentTarget && skipToContentTarget.current) {
skipToContentTarget.current.focus();
event?.preventDefault();
}
};

private handleNavigationDismiss = () => {
Expand Down

0 comments on commit 68d975d

Please sign in to comment.