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

[Search Filtering]: View More for Node Types Rendering with Default Limit of 4 Rows #2427

Merged
merged 1 commit into from
Nov 8, 2024
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
8 changes: 6 additions & 2 deletions src/components/App/SideBar/FilterSearch/NodeTypes/index.tsx
Original file line number Diff line number Diff line change
@@ -15,7 +15,11 @@ type Props = {
export const NodeTypes = ({ handleSchemaTypeClick, selectedTypes, schemaAll }: Props) => {
const [showAllSchemas, setShowAllSchemas] = useState(false)

const uniqueSchemas = (showAllSchemas ? schemaAll : schemaAll.slice(0, 4)).filter(
const schemasPerRow = 3
const MAX_ROWS = 4
const maxVisibleSchemas = schemasPerRow * MAX_ROWS

const uniqueSchemas = (showAllSchemas ? schemaAll : schemaAll.slice(0, maxVisibleSchemas)).filter(
(schema, index, self) => index === self.findIndex((s) => s.type === schema.type),
)

@@ -40,7 +44,7 @@ export const NodeTypes = ({ handleSchemaTypeClick, selectedTypes, schemaAll }: P
</SchemaType>
))}
</SchemaTypeWrapper>
{!showAllSchemas && schemaAll.length > 4 && (
{!showAllSchemas && schemaAll.length > maxVisibleSchemas && (
<ViewMoreButton onClick={() => setShowAllSchemas(true)}>
<PlusIconWrapper>
<PlusIcon /> View More
Loading