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: address search bar issue in the navbar #3444

Closed
wants to merge 4 commits into from

Conversation

allenhack638
Copy link
Contributor

@allenhack638 allenhack638 commented Dec 3, 2024

Description

This PR fixes the issue where the SearchBar was not showing on the navbar. It ensures the search bar is correctly rendered and behaves as expected.

image

Fixes

Fixes #3441: [BUG] SearchBar is not showing on the navbar

Summary by CodeRabbit

  • Style

    • Improved code readability through consistent formatting and indentation in the AlgoliaSearch component.
    • Reformatted import statements and type definitions for enhanced clarity.
    • Adjusted JSX structure for better readability in the AlgoliaSearch and SearchButton components.
  • New Features

    • Updated type signatures to include an optional indexName property for improved functionality in the SearchButton component.

Copy link

coderabbitai bot commented Dec 3, 2024

Walkthrough

The pull request introduces several formatting improvements and minor adjustments to the code structure in components/AlgoliaSearch.tsx. Key changes include the reformatting of import statements for better readability, enhancements to type definitions, and modifications to the formatting of functions and components to improve clarity and consistency. The changes focus on making the code more readable without altering its underlying logic or functionality.

Changes

File Change Summary
components/AlgoliaSearch.tsx Reformatted import statements, type definitions, and function signatures for improved readability. Adjusted formatting of JSX and props destructuring in AlgoliaSearch and SearchButton components.

Assessment against linked issues

Objective Addressed Explanation
Search bar should be rendered on the navbar (#3441) The changes do not address the rendering issue of the search icon in the SearchButton component.

🐰 In the code, I hop and play,
Formatting brightens up the way.
With props aligned and types so clear,
A search bar's charm will soon appear!
So let’s fix bugs and make it right,
For a navbar that shines, oh what a sight! ✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

Copy link

netlify bot commented Dec 3, 2024

Deploy Preview for asyncapi-website ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 4f439e3
🔍 Latest deploy log https://app.netlify.com/sites/asyncapi-website/deploys/675088502991f4000806e027
😎 Deploy Preview https://deploy-preview-3444--asyncapi-website.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@asyncapi-bot
Copy link
Contributor

asyncapi-bot commented Dec 3, 2024

⚡️ Lighthouse report for the changes in this PR:

Category Score
🔴 Performance 34
🟢 Accessibility 98
🟢 Best practices 92
🟢 SEO 100
🔴 PWA 33

Lighthouse ran on https://deploy-preview-3444--asyncapi-website.netlify.app/

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (3)
components/AlgoliaSearch.tsx (3)

Line range hint 341-397: Add default search icon to SearchButton

To ensure the search icon is always visible, we should provide a default IconLoupe when no children are provided.

export function SearchButton({
  children,
  indexName = INDEX_NAME,
  ...props
}: ISearchButtonProps) {
  const { onOpen, onInput } = useContext(SearchContext);
- const [Children, setChildren] = useState<string | React.ReactNode>('');
+ const [Children, setChildren] = useState<string | React.ReactNode>(<IconLoupe className="w-5 h-5" />);

  useEffect(() => {
    if (typeof children === 'function') {
      setChildren(children({ actionKey }));
    } else {
-     setChildren(children);
+     setChildren(children || <IconLoupe className="w-5 h-5" />);
    }
  }, [children]);
🧰 Tools
🪛 eslint

[error] 387-387: Replace "button" with 'button'

(prettier/prettier)


[error] 387-387: Unexpected usage of doublequote.

(jsx-quotes)


[error] 393-393: Replace "Search-Button" with 'Search-Button'

(prettier/prettier)


[error] 393-393: Unexpected usage of doublequote.

(jsx-quotes)


387-396: Enhance SearchButton accessibility

The button should have proper ARIA labels for better accessibility.

    <button
      type="button"
      ref={searchButtonRef}
      onClick={() => {
        onOpen(indexName);
      }}
      {...props}
      data-testid="Search-Button"
+     aria-label="Search"
+     role="search"
    >
🧰 Tools
🪛 eslint

[error] 387-387: Replace "button" with 'button'

(prettier/prettier)


[error] 387-387: Unexpected usage of doublequote.

(jsx-quotes)


[error] 393-393: Replace "Search-Button" with 'Search-Button'

(prettier/prettier)


[error] 393-393: Unexpected usage of doublequote.

(jsx-quotes)


Line range hint 1-397: Summary of Required Changes

The search bar visibility issue appears to be caused by:

  1. Missing IconLoupe import
  2. Lack of default icon implementation in SearchButton

Additional improvements suggested:

  1. Enhanced button accessibility
  2. Verification of CSS conflicts

Please implement the critical changes first to resolve the visibility issue.

🧰 Tools
🪛 eslint

[error] 303-303: Delete ,

(prettier/prettier)


[error] 303-303: Unexpected trailing comma.

(comma-dangle)


[error] 310-310: Delete ,

(prettier/prettier)


[error] 310-310: Unexpected trailing comma.

(comma-dangle)


[error] 316-320: Replace ⏎··········rel="preconnect"⏎··········href={https://${APP_ID}-dsn.algolia.net}⏎··········crossOrigin="anonymous"⏎······· with ·rel='preconnect'·href={https://${APP_ID}-dsn.algolia.net}·crossOrigin='anonymous'

(prettier/prettier)


[error] 317-317: Unexpected usage of doublequote.

(jsx-quotes)


[error] 319-319: Unexpected usage of doublequote.

(jsx-quotes)


[error] 322-324: Replace ⏎········{children}⏎······ with {children}

(prettier/prettier)


[error] 325-331: Replace (⏎········<AlgoliaModal⏎··········initialQuery={initialQuery·??·''}⏎··········onClose={onClose}⏎··········indexName={indexName}⏎········/>⏎······) with <AlgoliaModal·initialQuery={initialQuery·??·''}·onClose={onClose}·indexName={indexName}·/>

(prettier/prettier)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between ef509bd and 77fae5d.

📒 Files selected for processing (1)
  • components/AlgoliaSearch.tsx (17 hunks)
🧰 Additional context used
🪛 eslint
components/AlgoliaSearch.tsx

[error] 3-7: Replace ⏎··DocSearchHit,⏎··InternalDocSearchHit,⏎··StoredDocSearchHit,⏎ with ·DocSearchHit,·InternalDocSearchHit,·StoredDocSearchHit·

(prettier/prettier)


[error] 6-6: Unexpected trailing comma.

(comma-dangle)


[error] 12-19: Replace ⏎··createContext,⏎··useCallback,⏎··useContext,⏎··useEffect,⏎··useRef,⏎··useState,⏎ with ·createContext,·useCallback,·useContext,·useEffect,·useRef,·useState·

(prettier/prettier)


[error] 18-18: Unexpected trailing comma.

(comma-dangle)


[error] 60-63: Replace ⏎··React.ButtonHTMLAttributes<HTMLButtonElement>,⏎··'children'⏎ with React.ButtonHTMLAttributes<HTMLButtonElement>,·'children'

(prettier/prettier)


[error] 64-70: Replace ⏎····|·React.ReactNode⏎····|·(({⏎········actionKey,⏎······}:·{⏎········actionKey:·{·shortKey:·string;·key:·string·};⏎····· with ·React.ReactNode·|·(({·actionKey·}:·{·actionKey:·{·shortKey:·string;·key:·string·}

(prettier/prettier)


[error] 67-67: Unexpected trailing comma.

(comma-dangle)


[error] 87-88: Delete ⏎·····

(prettier/prettier)


[error] 99-100: Delete ⏎·······

(prettier/prettier)


[error] 101-105: Replace ⏎········item.type·!==·'lvl1'·&&⏎········items.length·>·1·&&⏎········items[0].type·===·'lvl1'·&&⏎······· with ·item.type·!==·'lvl1'·&&·items.length·>·1·&&·items[0].type·===·'lvl1'·&&

(prettier/prettier)


[error] 107-107: Delete ,

(prettier/prettier)


[error] 107-107: Unexpected trailing comma.

(comma-dangle)


[error] 126-126: Delete ,

(prettier/prettier)


[error] 126-126: Unexpected trailing comma.

(comma-dangle)


[error] 147-147: Delete ,

(prettier/prettier)


[error] 147-147: Unexpected trailing comma.

(comma-dangle)


[error] 149-153: Replace ⏎········indexName·===·DOCS_INDEX_NAME⏎··········?·'Search·documentation'⏎··········:·'Search·resources'⏎······ with indexName·===·DOCS_INDEX_NAME·?·'Search·documentation'·:·'Search·resources'

(prettier/prettier)


[error] 162-162: Delete ,

(prettier/prettier)


[error] 162-162: Unexpected trailing comma.

(comma-dangle)


[error] 170-170: Delete ,

(prettier/prettier)


[error] 170-170: Unexpected trailing comma.

(comma-dangle)


[error] 184-187: Replace ⏎····tagName·===·'INPUT'·||⏎····tagName·===·'SELECT'·||⏎··· with ·tagName·===·'INPUT'·||·tagName·===·'SELECT'·||

(prettier/prettier)


[error] 197-199: Replace ⏎······/(Mac|iPhone|iPod|iPad)/i.test(navigator.userAgent·||·navigator.platform)⏎···· with /(Mac|iPhone|iPod|iPad)/i.test(navigator.userAgent·||·navigator.platform)

(prettier/prettier)


[error] 202-202: Delete ,

(prettier/prettier)


[error] 202-202: Unexpected trailing comma.

(comma-dangle)


[error] 208-208: Delete ,

(prettier/prettier)


[error] 208-208: Unexpected trailing comma.

(comma-dangle)


[error] 214-214: Delete ,

(prettier/prettier)


[error] 214-214: Unexpected trailing comma.

(comma-dangle)


[error] 223-227: Replace ⏎··isOpen,⏎··onOpen,⏎··onClose,⏎ with ·isOpen,·onOpen,·onClose·

(prettier/prettier)


[error] 226-226: Unexpected trailing comma.

(comma-dangle)


[error] 253-255: Replace ⏎··············?·DOCS_INDEX_NAME⏎············· with ·?·DOCS_INDEX_NAME

(prettier/prettier)


[error] 275-279: Replace ⏎··children,⏎}:·{⏎··children:·React.ReactNode;⏎ with ·children·}:·{·children:·React.ReactNode·

(prettier/prettier)


[error] 276-276: Unexpected trailing comma.

(comma-dangle)


[error] 291-291: Delete ,

(prettier/prettier)


[error] 291-291: Unexpected trailing comma.

(comma-dangle)


[error] 303-303: Delete ,

(prettier/prettier)


[error] 303-303: Unexpected trailing comma.

(comma-dangle)


[error] 310-310: Delete ,

(prettier/prettier)


[error] 310-310: Unexpected trailing comma.

(comma-dangle)


[error] 316-320: Replace ⏎··········rel="preconnect"⏎··········href={https://${APP_ID}-dsn.algolia.net}⏎··········crossOrigin="anonymous"⏎······· with ·rel='preconnect'·href={https://${APP_ID}-dsn.algolia.net}·crossOrigin='anonymous'

(prettier/prettier)


[error] 317-317: Unexpected usage of doublequote.

(jsx-quotes)


[error] 319-319: Unexpected usage of doublequote.

(jsx-quotes)


[error] 322-324: Replace ⏎········{children}⏎······ with {children}

(prettier/prettier)


[error] 325-331: Replace (⏎········<AlgoliaModal⏎··········initialQuery={initialQuery·??·''}⏎··········onClose={onClose}⏎··········indexName={indexName}⏎········/>⏎······) with <AlgoliaModal·initialQuery={initialQuery·??·''}·onClose={onClose}·indexName={indexName}·/>

(prettier/prettier)


[error] 341-345: Replace ⏎··children,⏎··indexName·=·INDEX_NAME,⏎··...props⏎ with ·children,·indexName·=·INDEX_NAME,·...props·

(prettier/prettier)


[error] 359-363: Replace ⏎········searchButtonRef·&&⏎········searchButtonRef.current·===·document.activeElement·&&⏎········onInput⏎······ with searchButtonRef·&&·searchButtonRef.current·===·document.activeElement·&&·onInput

(prettier/prettier)


[error] 387-387: Replace "button" with 'button'

(prettier/prettier)


[error] 387-387: Unexpected usage of doublequote.

(jsx-quotes)


[error] 393-393: Replace "Search-Button" with 'Search-Button'

(prettier/prettier)


[error] 393-393: Unexpected usage of doublequote.

(jsx-quotes)

🔇 Additional comments (1)
components/AlgoliaSearch.tsx (1)

325-331: Verify modal and button styling

Let's ensure there are no CSS conflicts affecting the search icon visibility.

🧰 Tools
🪛 eslint

[error] 325-331: Replace (⏎········<AlgoliaModal⏎··········initialQuery={initialQuery·??·''}⏎··········onClose={onClose}⏎··········indexName={indexName}⏎········/>⏎······) with <AlgoliaModal·initialQuery={initialQuery·??·''}·onClose={onClose}·indexName={indexName}·/>

(prettier/prettier)

Comment on lines 1 to +19
/* eslint-disable no-underscore-dangle */
import { DocSearchModal } from '@docsearch/react';
import type { DocSearchHit, InternalDocSearchHit, StoredDocSearchHit } from '@docsearch/react/dist/esm/types';
import type {
DocSearchHit,
InternalDocSearchHit,
StoredDocSearchHit,
} from '@docsearch/react/dist/esm/types';
import clsx from 'clsx';
import Head from 'next/head';
import Link from 'next/link';
import { useRouter } from 'next/router';
import React, { createContext, useCallback, useContext, useEffect, useRef, useState } from 'react';
import React, {
createContext,
useCallback,
useContext,
useEffect,
useRef,
useState,
} from 'react';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Missing IconLoupe import

The PR objective mentions fixing the visibility of IconLoupe component, but the import statement for this component is missing. This could be the root cause of the search icon not being visible.

Add the following import:

import { DocSearchModal } from '@docsearch/react';
+ import { IconLoupe } from '@/components/icons';
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/* eslint-disable no-underscore-dangle */
import { DocSearchModal } from '@docsearch/react';
import type { DocSearchHit, InternalDocSearchHit, StoredDocSearchHit } from '@docsearch/react/dist/esm/types';
import type {
DocSearchHit,
InternalDocSearchHit,
StoredDocSearchHit,
} from '@docsearch/react/dist/esm/types';
import clsx from 'clsx';
import Head from 'next/head';
import Link from 'next/link';
import { useRouter } from 'next/router';
import React, { createContext, useCallback, useContext, useEffect, useRef, useState } from 'react';
import React, {
createContext,
useCallback,
useContext,
useEffect,
useRef,
useState,
} from 'react';
/* eslint-disable no-underscore-dangle */
import { DocSearchModal } from '@docsearch/react';
import { IconLoupe } from '@/components/icons';
import type {
DocSearchHit,
InternalDocSearchHit,
StoredDocSearchHit,
} from '@docsearch/react/dist/esm/types';
import clsx from 'clsx';
import Head from 'next/head';
import Link from 'next/link';
import { useRouter } from 'next/router';
import React, {
createContext,
useCallback,
useContext,
useEffect,
useRef,
useState,
} from 'react';
🧰 Tools
🪛 eslint

[error] 3-7: Replace ⏎··DocSearchHit,⏎··InternalDocSearchHit,⏎··StoredDocSearchHit,⏎ with ·DocSearchHit,·InternalDocSearchHit,·StoredDocSearchHit·

(prettier/prettier)


[error] 6-6: Unexpected trailing comma.

(comma-dangle)


[error] 12-19: Replace ⏎··createContext,⏎··useCallback,⏎··useContext,⏎··useEffect,⏎··useRef,⏎··useState,⏎ with ·createContext,·useCallback,·useContext,·useEffect,·useRef,·useState·

(prettier/prettier)


[error] 18-18: Unexpected trailing comma.

(comma-dangle)

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (1)
components/AlgoliaSearch.tsx (1)

325-331: Consider adding error boundary for modal rendering

While the conditional rendering is correct, consider wrapping the AlgoliaModal in an error boundary to gracefully handle potential rendering issues.

 {isOpen && (
+  <ErrorBoundary fallback={<div>Search is temporarily unavailable</div>}>
     <AlgoliaModal
       initialQuery={initialQuery ?? ''}
       onClose={onClose}
       indexName={indexName}
     />
+  </ErrorBoundary>
 )}
🧰 Tools
🪛 eslint

[error] 325-331: Replace (⏎········<AlgoliaModal⏎··········initialQuery={initialQuery·??·''}⏎··········onClose={onClose}⏎··········indexName={indexName}⏎········/>⏎······) with <AlgoliaModal·initialQuery={initialQuery·??·''}·onClose={onClose}·indexName={indexName}·/>

(prettier/prettier)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 77fae5d and b325adb.

📒 Files selected for processing (1)
  • components/AlgoliaSearch.tsx (17 hunks)
🧰 Additional context used
🪛 eslint
components/AlgoliaSearch.tsx

[error] 3-7: Replace ⏎··DocSearchHit,⏎··InternalDocSearchHit,⏎··StoredDocSearchHit,⏎ with ·DocSearchHit,·InternalDocSearchHit,·StoredDocSearchHit·

(prettier/prettier)


[error] 6-6: Unexpected trailing comma.

(comma-dangle)


[error] 12-19: Replace ⏎··createContext,⏎··useCallback,⏎··useContext,⏎··useEffect,⏎··useRef,⏎··useState,⏎ with ·createContext,·useCallback,·useContext,·useEffect,·useRef,·useState·

(prettier/prettier)


[error] 18-18: Unexpected trailing comma.

(comma-dangle)


[error] 60-63: Replace ⏎··React.ButtonHTMLAttributes<HTMLButtonElement>,⏎··'children'⏎ with React.ButtonHTMLAttributes<HTMLButtonElement>,·'children'

(prettier/prettier)


[error] 64-70: Replace ⏎····|·React.ReactNode⏎····|·(({⏎········actionKey,⏎······}:·{⏎········actionKey:·{·shortKey:·string;·key:·string·};⏎····· with ·React.ReactNode·|·(({·actionKey·}:·{·actionKey:·{·shortKey:·string;·key:·string·}

(prettier/prettier)


[error] 67-67: Unexpected trailing comma.

(comma-dangle)


[error] 87-88: Delete ⏎·····

(prettier/prettier)


[error] 99-100: Delete ⏎·······

(prettier/prettier)


[error] 101-105: Replace ⏎········item.type·!==·'lvl1'·&&⏎········items.length·>·1·&&⏎········items[0].type·===·'lvl1'·&&⏎······· with ·item.type·!==·'lvl1'·&&·items.length·>·1·&&·items[0].type·===·'lvl1'·&&

(prettier/prettier)


[error] 107-107: Delete ,

(prettier/prettier)


[error] 107-107: Unexpected trailing comma.

(comma-dangle)


[error] 126-126: Delete ,

(prettier/prettier)


[error] 126-126: Unexpected trailing comma.

(comma-dangle)


[error] 147-147: Delete ,

(prettier/prettier)


[error] 147-147: Unexpected trailing comma.

(comma-dangle)


[error] 149-153: Replace ⏎········indexName·===·DOCS_INDEX_NAME⏎··········?·'Search·documentation'⏎··········:·'Search·resources'⏎······ with indexName·===·DOCS_INDEX_NAME·?·'Search·documentation'·:·'Search·resources'

(prettier/prettier)


[error] 162-162: Delete ,

(prettier/prettier)


[error] 162-162: Unexpected trailing comma.

(comma-dangle)


[error] 170-170: Delete ,

(prettier/prettier)


[error] 170-170: Unexpected trailing comma.

(comma-dangle)


[error] 184-187: Replace ⏎····tagName·===·'INPUT'·||⏎····tagName·===·'SELECT'·||⏎··· with ·tagName·===·'INPUT'·||·tagName·===·'SELECT'·||

(prettier/prettier)


[error] 197-199: Replace ⏎······/(Mac|iPhone|iPod|iPad)/i.test(navigator.userAgent·||·navigator.platform)⏎···· with /(Mac|iPhone|iPod|iPad)/i.test(navigator.userAgent·||·navigator.platform)

(prettier/prettier)


[error] 202-202: Delete ,

(prettier/prettier)


[error] 202-202: Unexpected trailing comma.

(comma-dangle)


[error] 208-208: Delete ,

(prettier/prettier)


[error] 208-208: Unexpected trailing comma.

(comma-dangle)


[error] 214-214: Delete ,

(prettier/prettier)


[error] 214-214: Unexpected trailing comma.

(comma-dangle)


[error] 223-227: Replace ⏎··isOpen,⏎··onOpen,⏎··onClose,⏎ with ·isOpen,·onOpen,·onClose·

(prettier/prettier)


[error] 226-226: Unexpected trailing comma.

(comma-dangle)


[error] 253-255: Replace ⏎··············?·DOCS_INDEX_NAME⏎············· with ·?·DOCS_INDEX_NAME

(prettier/prettier)


[error] 275-279: Replace ⏎··children,⏎}:·{⏎··children:·React.ReactNode;⏎ with ·children·}:·{·children:·React.ReactNode·

(prettier/prettier)


[error] 276-276: Unexpected trailing comma.

(comma-dangle)


[error] 291-291: Delete ,

(prettier/prettier)


[error] 291-291: Unexpected trailing comma.

(comma-dangle)


[error] 303-303: Delete ,

(prettier/prettier)


[error] 303-303: Unexpected trailing comma.

(comma-dangle)


[error] 310-310: Delete ,

(prettier/prettier)


[error] 310-310: Unexpected trailing comma.

(comma-dangle)


[error] 316-320: Replace ⏎··········rel="preconnect"⏎··········href={https://${APP_ID}-dsn.algolia.net}⏎··········crossOrigin="anonymous"⏎······· with ·rel='preconnect'·href={https://${APP_ID}-dsn.algolia.net}·crossOrigin='anonymous'

(prettier/prettier)


[error] 317-317: Unexpected usage of doublequote.

(jsx-quotes)


[error] 319-319: Unexpected usage of doublequote.

(jsx-quotes)


[error] 322-324: Replace ⏎········{children}⏎······ with {children}

(prettier/prettier)


[error] 325-331: Replace (⏎········<AlgoliaModal⏎··········initialQuery={initialQuery·??·''}⏎··········onClose={onClose}⏎··········indexName={indexName}⏎········/>⏎······) with <AlgoliaModal·initialQuery={initialQuery·??·''}·onClose={onClose}·indexName={indexName}·/>

(prettier/prettier)


[error] 341-345: Replace ⏎··children,⏎··indexName·=·INDEX_NAME,⏎··...props⏎ with ·children,·indexName·=·INDEX_NAME,·...props·

(prettier/prettier)


[error] 359-363: Replace ⏎········searchButtonRef·&&⏎········searchButtonRef.current·===·document.activeElement·&&⏎········onInput⏎······ with searchButtonRef·&&·searchButtonRef.current·===·document.activeElement·&&·onInput

(prettier/prettier)


[error] 380-380: Replace else with ·else·

(prettier/prettier)


[error] 380-380: Expected space(s) before "else".

(keyword-spacing)


[error] 380-380: Expected space(s) after "else".

(keyword-spacing)


[error] 387-387: Replace "button" with 'button'

(prettier/prettier)


[error] 387-387: Unexpected usage of doublequote.

(jsx-quotes)


[error] 393-393: Replace "Search-Button" with 'Search-Button'

(prettier/prettier)


[error] 393-393: Unexpected usage of doublequote.

(jsx-quotes)

🔇 Additional comments (4)
components/AlgoliaSearch.tsx (4)

60-71: LGTM: Type definition enhancement

The addition of optional indexName to ISearchButtonProps is a good improvement for component flexibility.

🧰 Tools
🪛 eslint

[error] 60-63: Replace ⏎··React.ButtonHTMLAttributes<HTMLButtonElement>,⏎··'children'⏎ with React.ButtonHTMLAttributes<HTMLButtonElement>,·'children'

(prettier/prettier)


[error] 64-70: Replace ⏎····|·React.ReactNode⏎····|·(({⏎········actionKey,⏎······}:·{⏎········actionKey:·{·shortKey:·string;·key:·string·};⏎····· with ·React.ReactNode·|·(({·actionKey·}:·{·actionKey:·{·shortKey:·string;·key:·string·}

(prettier/prettier)


[error] 67-67: Unexpected trailing comma.

(comma-dangle)


87-88: LGTM: Improved readability of conditional logic

The reformatting of conditional statements in the transformItems function improves code readability while maintaining the same functionality.

Also applies to: 99-107

🧰 Tools
🪛 eslint

[error] 87-88: Delete ⏎·····

(prettier/prettier)


1-2: ⚠️ Potential issue

Missing IconLoupe import is causing the search icon visibility issue

The PR objective mentions fixing the visibility of IconLoupe component, but the import statement is still missing. This is the root cause of the search icon not being visible.

Add the following import:

import { DocSearchModal } from '@docsearch/react';
+ import { IconLoupe } from '@/components/icons';

341-345: Verify SearchButton usage across the codebase

Let's verify how SearchButton is being used to ensure consistent icon rendering.

✅ Verification successful

Based on the search results, I can now generate the final response:

SearchButton usage is consistent across the codebase

The SearchButton component is used consistently throughout the codebase with proper className props for styling and appropriate aria-labels for accessibility. All instances follow similar patterns:

  • Navigation components use it with hover/focus states and gray color scheme
  • Docs-related components use it with secondary color scheme and border styles
  • Hero section implements it with a prominent secondary color scheme

The IconLoupe implementation is also consistent, accepting an optional className prop that allows for flexible styling across different contexts.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for SearchButton usage patterns
echo "Searching for SearchButton usage patterns..."
rg -A 3 "<SearchButton" 

# Search for potential custom icon implementations
echo "Searching for potential custom icon implementations..."
rg -A 3 "IconLoupe.*className"

Length of output: 3328

🧰 Tools
🪛 eslint

[error] 341-345: Replace ⏎··children,⏎··indexName·=·INDEX_NAME,⏎··...props⏎ with ·children,·indexName·=·INDEX_NAME,·...props·

(prettier/prettier)

Comment on lines +387 to 396
type="button"
ref={searchButtonRef}
onClick={() => {
onOpen(indexName);
}}
{...props}
data-testid='Search-Button'
data-testid="Search-Button"
>
{Children}
</button>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add IconLoupe to button content

To address the visibility issue, ensure the IconLoupe is rendered within the button when no children are provided.

 <button
   type="button"
   ref={searchButtonRef}
   onClick={() => {
     onOpen(indexName);
   }}
   {...props}
   data-testid="Search-Button"
 >
-  {Children}
+  {Children || <IconLoupe className="h-5 w-5" />}
 </button>

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 eslint

[error] 387-387: Replace "button" with 'button'

(prettier/prettier)


[error] 387-387: Unexpected usage of doublequote.

(jsx-quotes)


[error] 393-393: Replace "Search-Button" with 'Search-Button'

(prettier/prettier)


[error] 393-393: Unexpected usage of doublequote.

(jsx-quotes)

@allenhack638
Copy link
Contributor Author

Apologies for the inconvenience caused due to the failed tests on this PR. After identifying the issue, I have made the necessary corrections and will re-upload the updated changes shortly.

@devilkiller-ag
Copy link
Member

devilkiller-ag commented Dec 4, 2024

Hi @allenhack638, It seems you have just made the formatting changes. Did any extension in your code editor do this formatting? If yes, then revert them.

You have to import and add the Loupe Icon in the SearchBar component. Feel free to ask any doubt if you have.

@allenhack638 allenhack638 closed this by deleting the head repository Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] SearchBar is not showing on the navbar
3 participants