mirror of
https://github.com/snowball-tools/snowballtools-base.git
synced 2024-12-22 08:27:44 +00:00
fix(ProjectSearchBarDialog): getMenuProps error
This commit is contained in:
parent
dee84f18cb
commit
37fff3c171
@ -1,7 +1,7 @@
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { useCombobox } from 'downshift';
|
||||
import { Project } from 'gql-client';
|
||||
import { useDebounce } from 'usehooks-ts';
|
||||
import { useDebounceValue } from 'usehooks-ts';
|
||||
|
||||
import SearchBar from 'components/SearchBar';
|
||||
import { useGQLClient } from 'context/GQLClientContext';
|
||||
@ -42,7 +42,7 @@ export const ProjectSearchBar = ({ onChange }: ProjectSearchBarProps) => {
|
||||
},
|
||||
});
|
||||
|
||||
const debouncedInputValue = useDebounce<string>(inputValue, 300);
|
||||
const [debouncedInputValue, _] = useDebounceValue<string>(inputValue, 300);
|
||||
|
||||
const fetchProjects = useCallback(
|
||||
async (inputValue: string) => {
|
||||
|
@ -5,7 +5,7 @@ import { CrossIcon, SearchIcon } from 'components/shared/CustomIcon';
|
||||
import { Input } from 'components/shared/Input';
|
||||
import { useGQLClient } from 'context/GQLClientContext';
|
||||
import { Project } from 'gql-client';
|
||||
import { useDebounce } from 'usehooks-ts';
|
||||
import { useDebounceValue } from 'usehooks-ts';
|
||||
import { ProjectSearchBarItem } from './ProjectSearchBarItem';
|
||||
import { ProjectSearchBarEmpty } from './ProjectSearchBarEmpty';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
@ -27,25 +27,30 @@ export const ProjectSearchBarDialog = ({
|
||||
const client = useGQLClient();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const { getInputProps, getItemProps, inputValue, setInputValue } =
|
||||
useCombobox({
|
||||
items,
|
||||
itemToString(item) {
|
||||
return item ? item.name : '';
|
||||
},
|
||||
selectedItem,
|
||||
onSelectedItemChange: ({ selectedItem: newSelectedItem }) => {
|
||||
if (newSelectedItem) {
|
||||
setSelectedItem(newSelectedItem);
|
||||
onClickItem?.(newSelectedItem);
|
||||
navigate(
|
||||
`/${newSelectedItem.organization.slug}/projects/${newSelectedItem.id}`,
|
||||
);
|
||||
}
|
||||
},
|
||||
});
|
||||
const {
|
||||
getInputProps,
|
||||
getItemProps,
|
||||
getMenuProps,
|
||||
inputValue,
|
||||
setInputValue,
|
||||
} = useCombobox({
|
||||
items,
|
||||
itemToString(item) {
|
||||
return item ? item.name : '';
|
||||
},
|
||||
selectedItem,
|
||||
onSelectedItemChange: ({ selectedItem: newSelectedItem }) => {
|
||||
if (newSelectedItem) {
|
||||
setSelectedItem(newSelectedItem);
|
||||
onClickItem?.(newSelectedItem);
|
||||
navigate(
|
||||
`/${newSelectedItem.organization.slug}/projects/${newSelectedItem.id}`,
|
||||
);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const debouncedInputValue = useDebounce<string>(inputValue, 300);
|
||||
const [debouncedInputValue, _] = useDebounceValue<string>(inputValue, 300);
|
||||
|
||||
const fetchProjects = useCallback(
|
||||
async (inputValue: string) => {
|
||||
@ -86,7 +91,7 @@ export const ProjectSearchBarDialog = ({
|
||||
</Button>
|
||||
</div>
|
||||
{/* Content */}
|
||||
<div className="flex flex-col gap-1 px-2 py-2">
|
||||
<div className="flex flex-col gap-1 px-2 py-2" {...getMenuProps()}>
|
||||
{items.length > 0
|
||||
? items.map((item, index) => (
|
||||
<>
|
||||
|
@ -32,7 +32,7 @@ const ProjectSearch = () => {
|
||||
return (
|
||||
<section className="h-full flex flex-col">
|
||||
{/* Header */}
|
||||
<div className="sticky hidden lg:block top-0 border-b bg-base-bg border-border-separator/[0.06] z-30">
|
||||
<div className="sticky hidden lg:block top-0 border-b bg-base-bg border-border-separator/[0.06] hover:z-30">
|
||||
<div className="flex pr-6 pl-2 py-2 items-center">
|
||||
<div className="flex-1">
|
||||
<ProjectSearchBar
|
||||
|
@ -0,0 +1,20 @@
|
||||
import { StoryObj, Meta } from '@storybook/react';
|
||||
|
||||
import { ProjectSearchBar } from 'components/projects/ProjectSearchBar';
|
||||
|
||||
const meta: Meta<typeof ProjectSearchBar> = {
|
||||
title: 'Components/ProjectSearchBar',
|
||||
component: ProjectSearchBar,
|
||||
tags: ['autodocs'],
|
||||
argTypes: {
|
||||
onChange: {
|
||||
action: 'change',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default meta;
|
||||
|
||||
type Story = StoryObj<typeof ProjectSearchBar>;
|
||||
|
||||
export const Default: Story = {};
|
Loading…
Reference in New Issue
Block a user