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

Add option that removes the See All Results link in the search results #491

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

WayneFerrao
Copy link

@WayneFerrao WayneFerrao commented Jan 23, 2025

Description

This PR adds an option, defaulted to false, to remove the See All Results link in the search results. This is meant as a workaround for the accessibility bug which prevents keyboard navigation to this link.

image

Related: #490

Summary by CodeRabbit

  • New Features

    • Added a configurable option to remove the "See All Results" button in search results
    • Users can now control the visibility of the search results footer link via a new removeSeeAllResults boolean setting
  • Configuration

    • New removeSeeAllResults option defaults to false
    • Allows fine-tuning of search result display behavior

Copy link

coderabbitai bot commented Jan 23, 2025

Walkthrough

The pull request introduces a new configuration option removeSeeAllResults to the Docusaurus local search plugin. This boolean option allows users to control the visibility of the "See All Results" link in search suggestions. The change spans multiple files, including the plugin's core configuration, server-side generation, option validation, and client-side rendering. The implementation ensures that the new option can be set during plugin configuration and is consistently applied throughout the search functionality.

Changes

File Change Summary
src/index.ts Added optional removeSeeAllResults boolean property to PluginOptions interface with default false
src/declarations.ts Exported new constant removeSeeAllResults in module declarations
src/server/utils/validateOptions.ts Added removeSeeAllResults validation with default false to plugin options schema
src/server/utils/generate.ts Incorporated removeSeeAllResults into generated configuration export
src/client/theme/SearchBar/SearchBar.tsx Updated search footer rendering to conditionally display "See All Results" link based on removeSeeAllResults
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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 Jan 23, 2025

Deploy Preview for easyops-cn-docusaurus-search-local ready!

Name Link
🔨 Latest commit e6cd33c
🔍 Latest deploy log https://app.netlify.com/sites/easyops-cn-docusaurus-search-local/deploys/6792d3d7b22bad0008007314
😎 Deploy Preview https://deploy-preview-491--easyops-cn-docusaurus-search-local.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

@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: 0

🧹 Nitpick comments (1)
docusaurus-search-local/src/client/theme/SearchBar/SearchBar.tsx (1)

284-286: Simplify the condition for clarity

Instead of explicitly checking === false, consider using a simpler boolean check:

- if(removeSeeAllResults === false){
+ if (!removeSeeAllResults) {
    div.appendChild(a);
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f64b972 and e6cd33c.

📒 Files selected for processing (5)
  • docusaurus-search-local/src/client/theme/SearchBar/SearchBar.tsx (2 hunks)
  • docusaurus-search-local/src/declarations.ts (1 hunks)
  • docusaurus-search-local/src/index.ts (1 hunks)
  • docusaurus-search-local/src/server/utils/generate.ts (2 hunks)
  • docusaurus-search-local/src/server/utils/validateOptions.ts (1 hunks)
🔇 Additional comments (5)
docusaurus-search-local/src/declarations.ts (1)

16-16: Add new boolean property for search results removal.

Declaring removeSeeAllResults as a boolean here is consistent with the plugin's default. Ensure callers handle it properly even when no explicit user configuration is provided.

docusaurus-search-local/src/server/utils/validateOptions.ts (1)

35-35: New boolean property validated with a default value.

Adding removeSeeAllResults here with a default of false aligns with the PR objective, and the approach is consistent with the rest of the schema.

docusaurus-search-local/src/server/utils/generate.ts (1)

Line range hint 23-38: Consistent export of the new property in generate function.

Destructuring removeSeeAllResults and exporting it matches the existing pattern. No issues with JSON stringification or naming consistency.

docusaurus-search-local/src/index.ts (1)

202-208: Optional plugin option documented correctly.

The addition of removeSeeAllResults?: boolean with a clear doc block and default behavior aligns perfectly with the PR’s objective. Good job keeping the documentation thorough.

docusaurus-search-local/src/client/theme/SearchBar/SearchBar.tsx (1)

33-33: New variable import looks good

This newly introduced variable aligns with the PR goal to conditionally remove the footer link.

@@ -280,7 +281,9 @@ export default function SearchBar({
const a = searchFooterLinkElement({ query, isEmpty });
const div = document.createElement("div");
div.className = styles.hitFooter;
div.appendChild(a);
if(removeSeeAllResults === false){
div.appendChild(a);
Copy link
Member

Choose a reason for hiding this comment

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

For me, the main issue currently is when I enter some words in the search box, then press the tab key, it jumped to one of the search target page instead of switching between result items. This won't fix it, will it?

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, this won't fix the tab issue. That functionality is in the @easyops-cn/autocomplete.js library, if I'm not mistaken.

Copy link
Member

Choose a reason for hiding this comment

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

Then I'm not sure what this PR fixes

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.

2 participants