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 bug #3676 : Display consistent search history for Search documentation and Search resources. #3854

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Sharanshetty658
Copy link

@Sharanshetty658 Sharanshetty658 commented Mar 9, 2025

Made changes in:

  • components/AlgoliaSearch.tsx
  • components/navigation/DocsMobileMenu.tsx
  • components/navigation/DocsNavWrapper.tsx
  • components/navigation/MobileNavMenu.tsx
  • components/navigation/NavBar.tsx

Description:

-This PR fixes the Inconsistency shown for the recent searches displayed by the Search Bar and the Search Icon.

Fixes Bug : #3676

Summary by CodeRabbit

  • Refactor
    • Standardized the search functionality across the navigation and modal areas to consistently use the same search index. This update streamlines the search experience on both mobile and desktop views by ensuring uniform behavior without altering the overall structure or existing functionality.

Copy link
Contributor

coderabbitai bot commented Mar 9, 2025

Walkthrough

This change standardizes the use of a constant INDEX_NAME (set as 'asyncapi') for Algolia search components. The indexName prop is now passed consistently using INDEX_NAME instead of relying on function parameters or previously named constants (e.g., DOCS_INDEX_NAME) across various components. The core functionality of modal handling and search logic remains unchanged.

Changes

File(s) Change Summary
components/AlgoliaSearch.tsx Changed the DocSearchModal prop from a dynamic value to the constant INDEX_NAME ('asyncapi').
components/navigation/DocsMobileMenu.tsx,
components/navigation/DocsNavWrapper.tsx
Replaced import of DOCS_INDEX_NAME with INDEX_NAME and updated the SearchButton prop accordingly.
components/navigation/MobileNavMenu.tsx,
components/navigation/NavBar.tsx
Added or updated the indexName prop in SearchButton to use INDEX_NAME in both mobile and main navigation components.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant NB as NavBar/MobileNavMenu
    participant SB as SearchButton
    participant AS as AlgoliaSearch Modal

    U->>NB: Initiates search action
    NB->>SB: Renders SearchButton with INDEX_NAME
    SB->>AS: Opens modal with INDEX_NAME parameter
Loading

Possibly related PRs

Suggested labels

ready-to-merge

Suggested reviewers

  • derberg
  • magicmatatjahu
  • akshatnema
  • sambhavgupta0705
  • anshgoyalevil
  • devilkiller-ag
  • asyncapi-bot-eve
  • Mayaleeeee

Poem

I'm a rabbit in the code, hopping through the stream,
Found a constant path where dynamic values once did gleam.
With INDEX_NAME fixed and true, our search now feels so bright,
Each component sings in unison, coding through the night.
Celebrate the steady beat of code—a merry, rhythmic delight!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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 generate docstrings to generate docstrings for this 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

netlify bot commented Mar 9, 2025

Deploy Preview for asyncapi-website ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 73bb1b2
🔍 Latest deploy log https://app.netlify.com/sites/asyncapi-website/deploys/67ce9cd1a8c8b20008a137d7
😎 Deploy Preview https://deploy-preview-3854--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.

Copy link

codecov bot commented Mar 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (d18e10c) to head (73bb1b2).

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #3854   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           21        21           
  Lines          667       667           
  Branches       113       113           
=========================================
  Hits           667       667           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@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

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 73b8496 and 74f6c96.

📒 Files selected for processing (5)
  • components/AlgoliaSearch.tsx (1 hunks)
  • components/navigation/DocsMobileMenu.tsx (2 hunks)
  • components/navigation/DocsNavWrapper.tsx (2 hunks)
  • components/navigation/MobileNavMenu.tsx (2 hunks)
  • components/navigation/NavBar.tsx (3 hunks)
⏰ Context from checks skipped due to timeout of 180000ms (4)
  • GitHub Check: Redirect rules - asyncapi-website
  • GitHub Check: Header rules - asyncapi-website
  • GitHub Check: Pages changed - asyncapi-website
  • GitHub Check: Lighthouse CI
🔇 Additional comments (8)
components/navigation/NavBar.tsx (3)

9-9: Import change supports the standardization of search index.

Importing INDEX_NAME constant allows consistent indexing across the application's search functionality, which addresses the inconsistent search history issue.


163-163: Consistent search history implementation.

Using the standardized INDEX_NAME for the mobile search button ensures users will see the same search history across all search interfaces.


224-224: Standardized search index implementation.

Using the same INDEX_NAME for the main navigation search button aligns with the fix for inconsistent search history display.

components/navigation/DocsNavWrapper.tsx (2)

5-5: Import change from DOCS_INDEX_NAME to INDEX_NAME.

This change supports the standardization of search indices across the application, addressing the inconsistent search history issue.


28-28: Standardized search index implementation.

Using the consistent INDEX_NAME instead of the previously used DOCS_INDEX_NAME ensures that searches from the docs navigation will share history with other search components in the application.

components/navigation/DocsMobileMenu.tsx (2)

5-5: Import change from DOCS_INDEX_NAME to INDEX_NAME.

This change supports the standardization of search indices across the application, addressing the inconsistent search history issue.


51-51: Standardized search index for mobile docs menu.

Using the consistent INDEX_NAME instead of the previously used DOCS_INDEX_NAME ensures that searches from the mobile docs menu will share history with other search components.

components/navigation/MobileNavMenu.tsx (1)

6-6: LGTM! Consistent use of INDEX_NAME improves search history integration.

The change properly imports and implements the standardized INDEX_NAME constant, which directly addresses the bug described in PR #3676 regarding inconsistent search history display. Using a shared constant across search components ensures that search history will be consistent across the application.

Also applies to: 70-70

@@ -122,7 +122,7 @@ function AlgoliaModal({ onClose, initialQuery, indexName }: AlgoliaModalProps) {
}}
placeholder={indexName === DOCS_INDEX_NAME ? 'Search documentation' : 'Search resources'}
onClose={onClose}
indexName={indexName}
indexName={INDEX_NAME}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Critical fix for search history consistency.

This is the core change that standardizes the search index. By forcing the DocSearchModal to always use INDEX_NAME instead of the passed indexName parameter, all search components will now share the same search history.

It's worth noting that this change means the placeholder prop (in line 123) may show different text than what's being searched, as it still uses the passed indexName to determine whether to show "Search documentation" or "Search resources".

@sambhavgupta0705
Copy link
Member

@Sharanshetty658 can you please explain to me the issue first

@Sharanshetty658
Copy link
Author

@sambhavgupta0705
So the problem is that on the docs page, there are two ways of searching: one is via the Search bar on the left side and the other via the Search Icon on the nav bar. However, when you individually search for them, the recent searches on both are inconsistent.

Search Bar:

image

Search Icon:

image

@Sharanshetty658
Copy link
Author

Sharanshetty658 commented Mar 11, 2025

@AceTheCreator @anshgoyalevil Can you please review this PR. Thank you

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.

3 participants