Skip to content

feat(MeiliSearch): update css#584

Merged
ArgoZhang merged 5 commits intomasterfrom
refactor-search
Oct 9, 2025
Merged

feat(MeiliSearch): update css#584
ArgoZhang merged 5 commits intomasterfrom
refactor-search

Conversation

@ArgoZhang
Copy link
Copy Markdown
Member

@ArgoZhang ArgoZhang commented Oct 9, 2025

Link issues

fixes #583

Summary By Copilot

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

Refactor MeiliSearchBox styling and initialization logic to use new CSS classes for better layout control and hide components by default until JavaScript initializes and displays them.

Enhancements:

  • Introduce a .bb-g-search class for the global search container with flex layout, custom paddings, border, transitions, and placeholder styling
  • Refactor .search-dialog-mask into a fixed, centered overlay with translucent background and hide it by default using d-none
  • Hide the search box by default using visually-hidden and reveal both the box and mask during initialization in the JS module
  • Update the MeiliSearchBox component markup and class builder to include visually-hidden on the search container and d-none on the mask

Copilot AI review requested due to automatic review settings October 9, 2025 08:22
@bb-auto bb-auto Bot added the enhancement New feature or request label Oct 9, 2025
@bb-auto bb-auto Bot added this to the v9.2.0 milestone Oct 9, 2025
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Oct 9, 2025

Reviewer's Guide

This PR refactors the MeiliSearch component’s styling by introducing a new .bb-g-search wrapper with CSS variables and updated input/hover rules, consolidates mask styles into a single responsive block (hidden by default), and shifts visibility control to the initialization script by toggling visually-hidden/d-none classes in both markup and code-behind.

Class diagram for MeiliSearchBox visibility logic update

classDiagram
    class MeiliSearchBox {
        +RenderFragment? FooterTemplate
        -string? ClassString
    }
    MeiliSearchBox : ClassString
    note for MeiliSearchBox "ClassString now includes 'visually-hidden' by default"
Loading

File-Level Changes

Change Details Files
Refactor search box styling into .bb-g-search with custom properties
  • Define --bb-global-search-* variables for padding, width, colors
  • Apply flex layout, border, radius and transition rules
  • Add hover state and nested input/placeholder styling
src/components/BootstrapBlazor.MeiliSearch/wwwroot/meilisearch.css
Consolidate and hide mask styles by default
  • Merge duplicate .search-dialog-mask blocks into one
  • Set position, flex-centering, background-color and z-index
  • Add display: none to hide mask until init
src/components/BootstrapBlazor.MeiliSearch/wwwroot/meilisearch.css
Shift visibility control to init script
  • Remove visually-hidden from root element in init()
  • Query and remove d-none from mask element
  • Update mask assignment to use the new variable
src/components/BootstrapBlazor.MeiliSearch/MeiliSearchBox.razor.js
Apply default hiding classes in markup and code-behind
  • Add d-none to mask <div> in Razor markup
  • Include visually-hidden in CSS builder for wrapper in code-behind
src/components/BootstrapBlazor.MeiliSearch/MeiliSearchBox.razor
src/components/BootstrapBlazor.MeiliSearch/MeiliSearchBox.razor.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#583 Update the CSS for the MeiliSearch component.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the CSS styling and visibility behavior for the MeiliSearch component to fix issue #583. The changes improve the initial rendering state and component structure.

  • Updated CSS styles for the search component with new .bb-g-search styling rules
  • Modified the initialization to show the component and dialog mask after CSS is loaded
  • Added versioning update to reflect the changes

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
meilisearch.css Added new CSS rules for .bb-g-search styling and reorganized existing dialog mask styles
MeiliSearchBox.razor.js Added logic to remove visually-hidden and d-none classes during initialization
MeiliSearchBox.razor.cs Added visually-hidden class to default component styling
MeiliSearchBox.razor Added d-none class to search dialog mask
BootstrapBlazor.MeiliSearch.csproj Incremented version from 9.1.10 to 9.1.11

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

z-index: var(--bb-global-search-dialog-mask-z-index);
background-color: rgba(var(--bs-emphasis-color-rgb), 0.3);
justify-content: center;
display: none;
Copy link

Copilot AI Oct 9, 2025

Choose a reason for hiding this comment

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

Using display: none directly in CSS conflicts with the JavaScript logic that removes the d-none class. Consider using display: none !important or rely solely on the Bootstrap d-none class for consistency.

Suggested change
display: none;

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • The CSS hover rule uses --bb-border-hover-color, which isn’t defined—update it to a valid variable (e.g. --bs-border-hover-color) or declare the custom one.
  • Instead of mixing visually-hidden with component logic, consider using d-none to toggle the search box visibility for a cleaner and more predictable hide/show behavior.
  • The init script removes hide classes on mount but never reinstates them on close or dispose—consider adding teardown logic to re-add d-none/visually-hidden when the dialog is closed to avoid it remaining visible.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The CSS hover rule uses `--bb-border-hover-color`, which isn’t defined—update it to a valid variable (e.g. `--bs-border-hover-color`) or declare the custom one.
- Instead of mixing `visually-hidden` with component logic, consider using `d-none` to toggle the search box visibility for a cleaner and more predictable hide/show behavior.
- The init script removes hide classes on mount but never reinstates them on close or dispose—consider adding teardown logic to re-add `d-none`/`visually-hidden` when the dialog is closed to avoid it remaining visible.

## Individual Comments

### Comment 1
<location> `src/components/BootstrapBlazor.MeiliSearch/wwwroot/meilisearch.css:18-25` </location>
<code_context>
+        border: var(--bs-border-width) solid var(--bb-border-hover-color);
+    }
+
+    .bb-g-search > input {
+        width: 100%;
+        background-color: transparent;
+        border: none;
+        line-height: 1.5;
+        padding: 0;
+        cursor: pointer;
+    }
+
</code_context>

<issue_to_address>
**suggestion:** Consider using 'cursor: text' for input fields instead of 'pointer'.

Using 'cursor: pointer' on text inputs can confuse users and affect accessibility. If the input is not editable and opens a dialog, make the interaction clear.

```suggestion
    .bb-g-search > input {
        width: 100%;
        background-color: transparent;
        border: none;
        line-height: 1.5;
        padding: 0;
        cursor: text;
    }
```
</issue_to_address>

### Comment 2
<location> `src/components/BootstrapBlazor.MeiliSearch/MeiliSearchBox.razor.cs:115` </location>
<code_context>
     public RenderFragment? FooterTemplate { get; set; }

-    private string? ClassString => CssBuilder.Default("bb-g-search")
+    private string? ClassString => CssBuilder.Default("bb-g-search visually-hidden")
         .AddClassFromAttributes(AdditionalAttributes)
         .Build();
</code_context>

<issue_to_address>
**issue:** Adding 'visually-hidden' to the root class may affect layout and accessibility.

If you intend to keep the search container accessible while hiding it visually, use a utility class or ARIA attributes designed for that purpose. Also, verify that visibility toggling works as expected on initialization.
</issue_to_address>

### Comment 3
<location> `src/components/BootstrapBlazor.MeiliSearch/MeiliSearchBox.razor.js:12-18` </location>
<code_context>
 export async function init(id, options) {
     const el = document.getElementById(id);
     await addLink('_content/BootstrapBlazor.MeiliSearch/meilisearch.css');
+    el.classList.remove('visually-hidden');
+
+    const mask = el.querySelector('.search-dialog-mask');
</code_context>

<issue_to_address>
**suggestion (bug_risk):** Directly removing 'visually-hidden' class may cause layout shifts if initialization is delayed.

Ensure the element is revealed only after all required resources are loaded to prevent layout shifts or flashes of unstyled content.

```suggestion
    await addLink('_content/BootstrapBlazor.MeiliSearch/meilisearch.css');

    const mask = el.querySelector('.search-dialog-mask');
    mask.classList.remove("d-none");

    await addScript('_content/BootstrapBlazor.MeiliSearch/meilisearch.umd.min.js');
    el.classList.remove('visually-hidden');
```
</issue_to_address>

### Comment 4
<location> `src/components/BootstrapBlazor.MeiliSearch/MeiliSearchBox.razor:8` </location>
<code_context>
     <i class="fa-solid fa-search search-dialog-icon"></i>
     <input type="text" readonly placeholder="@SearchBoxPlaceHolder" />
-    <div class="search-dialog-mask">
+    <div class="search-dialog-mask d-none">
         <div class="search-dialog shadow-lg" tabindex="0">
             <header class="search-dialog-input">
</code_context>

<issue_to_address>
**suggestion:** Using both 'd-none' and 'display: none' in CSS may lead to specificity conflicts.

Standardize the method for toggling mask visibility to avoid CSS specificity issues and ensure consistent behavior.

Suggested implementation:

```
    <div class="search-dialog-mask @(IsMaskVisible ? "" : "d-none")">

```

1. You will need to define a `bool IsMaskVisible` property in your component's code-behind or `@code` block.
2. Update any logic that shows/hides the mask to set `IsMaskVisible` to `true` or `false` as appropriate.
3. Remove any other usage of inline `style="display: none"` for `.search-dialog-mask` in this file.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +18 to +25
.bb-g-search > input {
width: 100%;
background-color: transparent;
border: none;
line-height: 1.5;
padding: 0;
cursor: pointer;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Consider using 'cursor: text' for input fields instead of 'pointer'.

Using 'cursor: pointer' on text inputs can confuse users and affect accessibility. If the input is not editable and opens a dialog, make the interaction clear.

Suggested change
.bb-g-search > input {
width: 100%;
background-color: transparent;
border: none;
line-height: 1.5;
padding: 0;
cursor: pointer;
}
.bb-g-search > input {
width: 100%;
background-color: transparent;
border: none;
line-height: 1.5;
padding: 0;
cursor: text;
}

public RenderFragment? FooterTemplate { get; set; }

private string? ClassString => CssBuilder.Default("bb-g-search")
private string? ClassString => CssBuilder.Default("bb-g-search visually-hidden")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue: Adding 'visually-hidden' to the root class may affect layout and accessibility.

If you intend to keep the search container accessible while hiding it visually, use a utility class or ARIA attributes designed for that purpose. Also, verify that visibility toggling works as expected on initialization.

Comment on lines 12 to 18
await addLink('_content/BootstrapBlazor.MeiliSearch/meilisearch.css');
el.classList.remove('visually-hidden');

const mask = el.querySelector('.search-dialog-mask');
mask.classList.remove("d-none");

await addScript('_content/BootstrapBlazor.MeiliSearch/meilisearch.umd.min.js');
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion (bug_risk): Directly removing 'visually-hidden' class may cause layout shifts if initialization is delayed.

Ensure the element is revealed only after all required resources are loaded to prevent layout shifts or flashes of unstyled content.

Suggested change
await addLink('_content/BootstrapBlazor.MeiliSearch/meilisearch.css');
el.classList.remove('visually-hidden');
const mask = el.querySelector('.search-dialog-mask');
mask.classList.remove("d-none");
await addScript('_content/BootstrapBlazor.MeiliSearch/meilisearch.umd.min.js');
await addLink('_content/BootstrapBlazor.MeiliSearch/meilisearch.css');
const mask = el.querySelector('.search-dialog-mask');
mask.classList.remove("d-none");
await addScript('_content/BootstrapBlazor.MeiliSearch/meilisearch.umd.min.js');
el.classList.remove('visually-hidden');

<i class="fa-solid fa-search search-dialog-icon"></i>
<input type="text" readonly placeholder="@SearchBoxPlaceHolder" />
<div class="search-dialog-mask">
<div class="search-dialog-mask d-none">
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Using both 'd-none' and 'display: none' in CSS may lead to specificity conflicts.

Standardize the method for toggling mask visibility to avoid CSS specificity issues and ensure consistent behavior.

Suggested implementation:

    <div class="search-dialog-mask @(IsMaskVisible ? "" : "d-none")">

  1. You will need to define a bool IsMaskVisible property in your component's code-behind or @code block.
  2. Update any logic that shows/hides the mask to set IsMaskVisible to true or false as appropriate.
  3. Remove any other usage of inline style="display: none" for .search-dialog-mask in this file.

@ArgoZhang ArgoZhang merged commit 114461a into master Oct 9, 2025
2 checks passed
@ArgoZhang ArgoZhang deleted the refactor-search branch October 9, 2025 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(MeiliSearch): update css

2 participants