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(command palette): remove dual focus functionality #1657

Open
wants to merge 2 commits into
base: feature-command-palette
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { fireEvent } from '@testing-library/react'
import userEvent from '@testing-library/user-event'

Check warning on line 2 in components/header-bar/src/command-palette/__tests__/browse-apps-view.test.js

View workflow job for this annotation

GitHub Actions / lint

Using exported name 'userEvent' as identifier for default export
import React from 'react'
import CommandPalette from '../command-palette.js'
import {
Expand Down Expand Up @@ -122,13 +122,10 @@
'Test App 1'
)

// simulate hover
// simulate hover - no highlight
await user.hover(listItems[8])
expect(listItems[1]).not.toHaveClass('highlighted')
expect(listItems[8]).toHaveClass('highlighted')
expect(listItems[8].querySelector('span')).toHaveTextContent(
'Test App 9'
)
expect(listItems[0]).toHaveClass('highlighted')
expect(listItems[8]).not.toHaveClass('highlighted')

const clearButton = getAllByRole('button')[1]
await user.click(clearButton)
Expand Down
10 changes: 2 additions & 8 deletions components/header-bar/src/command-palette/sections/app-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@ import cx from 'classnames'
import PropTypes from 'prop-types'
import React from 'react'

function AppItem({ name, path, img, highlighted, handleMouseEnter }) {
function AppItem({ name, path, img, highlighted }) {
return (
<a
href={path}
className={cx('item', { highlighted })}
onMouseEnter={handleMouseEnter}
tabIndex={-1}
>
<a href={path} className={cx('item', { highlighted })} tabIndex={-1}>
<img src={img} alt="app" className="app-icon" />
<span className="app-name">{name}</span>
<style jsx>{`
Expand Down Expand Up @@ -51,7 +46,6 @@ function AppItem({ name, path, img, highlighted, handleMouseEnter }) {
}

AppItem.propTypes = {
handleMouseEnter: PropTypes.func,
highlighted: PropTypes.bool,
img: PropTypes.string,
name: PropTypes.string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ function ListItem({
onClickHandler,
highlighted,
dataTest = 'headerbar-list-item',
handleMouseEnter,
}) {
const showDescription = type === 'commands'
return (
Expand All @@ -22,7 +21,6 @@ function ListItem({
onClick={onClickHandler}
className={cx('item', { highlighted })}
data-test={dataTest}
onMouseEnter={handleMouseEnter}
tabIndex={-1}
>
<div className="icon">
Expand Down Expand Up @@ -100,7 +98,6 @@ function ListItem({
ListItem.propTypes = {
dataTest: PropTypes.string,
description: PropTypes.string,
handleMouseEnter: PropTypes.func,
highlighted: PropTypes.bool,
icon: PropTypes.node,
image: PropTypes.string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useCommandPaletteContext } from '../context/command-palette-context.js'
import ListItem from './list-item.js'

function List({ filteredItems, type }) {
const { highlightedIndex, setHighlightedIndex } = useCommandPaletteContext()
const { highlightedIndex } = useCommandPaletteContext()
return (
<div data-test="headerbar-list">
{filteredItems.map(
Expand All @@ -20,7 +20,6 @@ function List({ filteredItems, type }) {
image={icon}
description={description}
highlighted={highlightedIndex === idx}
handleMouseEnter={() => setHighlightedIndex(idx)}
/>
)
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ function HomeView({ apps, commands, shortcuts, actions }) {
highlightedIndex,
setHighlightedIndex,
activeSection,
setActiveSection,
} = useCommandPaletteContext()
const filteredItems = apps.concat(commands, shortcuts)
const topApps = apps?.slice(0, 8)
Expand Down Expand Up @@ -54,10 +53,6 @@ function HomeView({ apps, commands, shortcuts, actions }) {
activeSection === 'grid' &&
highlightedIndex === idx
}
handleMouseEnter={() => {
setActiveSection('grid')
setHighlightedIndex(idx)
}}
/>
)
)}
Expand Down Expand Up @@ -118,10 +113,6 @@ function HomeView({ apps, commands, shortcuts, actions }) {
activeSection === 'actions' &&
highlightedIndex === index
}
handleMouseEnter={() => {
setActiveSection('actions')
setHighlightedIndex(index)
}}
/>
)
}
Expand Down
Loading