Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Commit

Permalink
Fix bug with no search results
Browse files Browse the repository at this point in the history
  • Loading branch information
nastyastavitskaya committed Mar 18, 2024
1 parent c2911d2 commit 649d708
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { userEvent, screen } from '@storybook/test'
import React from 'react'
import { type Meta } from '@storybook/react'
import { type StoryObj } from '@storybook/react'
Expand Down Expand Up @@ -914,4 +915,36 @@ export const Cortex: Story = {
alert('going to overview map')
},
},
}

export const WorkspaceSearchWithNoResults: Meta<typeof GlobalNavigation> = {
render: args => (
<Center style={{ minHeight: '800px' }}>
<GlobalNavigation {...args}></GlobalNavigation>
</Center>
),

args: {
onSearchClick: () => {
alert('Searching!')
},
logo: mpLogo,
tools: mpTools,
management: mpManagement,
orgs: mpOrgs,
onMpHomeClick: () => {
alert('going to overview map')
},
avatarOptions: {
// src: "https://static-qa1.qa.corp.mparticle.com/appimg/logo_af_916397d2-9732-8de6-77cc-80e3bba120ca.png",
alt: 'avatar',
},
},
play: async () => {
const workspaceSelector = screen.getByText('_W2')
await userEvent.hover(workspaceSelector)

const searchInput = await screen.findByPlaceholderText('Search')
await userEvent.type(searchInput, '123{enter}')
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export function WorkspaceSelector(props: IWorkspaceSelectorProps) {

const workspaceInitials = getInitials(activeWorkspace?.label)

const hasSearchInput = menuItems.filter(item => !!item.label).length > 5
const hasSearchInput = !!searchTerm || menuItems.filter(item => !!item.label).length > 5

// This seems to be the only way of consistently focusing the input on the first open
// We should find a better way to do this and not rely on setTimout
Expand Down

0 comments on commit 649d708

Please sign in to comment.