Skip to content
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: disable escape handler for sidebar #8994

Merged
merged 1 commit into from
Sep 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 2 additions & 16 deletions plugins/plugin-client-common/src/components/Client/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import React from 'react'
import { encodeComponent, i18n, pexecInCurrentTab } from '@kui-shell/core'
import { encodeComponent, pexecInCurrentTab } from '@kui-shell/core'
import { PageSidebar, PageSidebarProps } from '@patternfly/react-core'

import CommonProps from './props/Common'
Expand All @@ -29,8 +29,6 @@ const NavItem = React.lazy(() => import('@patternfly/react-core').then(_ => ({ d
const NavList = React.lazy(() => import('@patternfly/react-core').then(_ => ({ default: _.NavList })))
const NavExpandable = React.lazy(() => import('@patternfly/react-core').then(_ => ({ default: _.NavExpandable })))

const strings = i18n('plugin-client-common')

type Props = Pick<CommonProps, 'noTopTabs'> &
BrandingProps &
GuidebookProps & {
Expand Down Expand Up @@ -63,17 +61,6 @@ export default class Sidebar extends React.PureComponent<Props, State> {
return this.state ? this.state.currentGuidebook : undefined
}

private readonly onKeyup = (evt: KeyboardEvent) => {
if (evt.key === 'Escape') {
this.props.toggleOpen()
}
}

public componentDidMount() {
document.addEventListener('keyup', this.onKeyup)
this.cleaners.push(() => document.removeEventListener('keyup', this.onKeyup))
}

public componentWillUnmount() {
this.cleaners.forEach(_ => _())
}
Expand All @@ -84,8 +71,7 @@ export default class Sidebar extends React.PureComponent<Props, State> {
this.props.productName &&
this.props.version && (
<div className="kui--tab-container-sidebar-other flex-layout">
<span className="flex-fill sub-text">{strings('Toggle via <Esc>')}</span>
<span className="inline-flex flex-align-end semi-bold">v{this.props.version}</span>
<span className="inline-flex flex-fill flex-align-end semi-bold">v{this.props.version}</span>
</div>
)
)
Expand Down