Conversation
Reviewer's GuideThis PR refactors the MeiliSearch component’s styling by introducing a new Class diagram for MeiliSearchBox visibility logic updateclassDiagram
class MeiliSearchBox {
+RenderFragment? FooterTemplate
-string? ClassString
}
MeiliSearchBox : ClassString
note for MeiliSearchBox "ClassString now includes 'visually-hidden' by default"
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
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-searchstyling 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; |
There was a problem hiding this comment.
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.
| display: none; |
There was a problem hiding this comment.
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-hiddenwith component logic, consider usingd-noneto 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-hiddenwhen 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>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| .bb-g-search > input { | ||
| width: 100%; | ||
| background-color: transparent; | ||
| border: none; | ||
| line-height: 1.5; | ||
| padding: 0; | ||
| cursor: pointer; | ||
| } |
There was a problem hiding this comment.
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.
| .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") |
There was a problem hiding this comment.
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.
| 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'); |
There was a problem hiding this comment.
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.
| 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"> |
There was a problem hiding this comment.
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")">
- You will need to define a
bool IsMaskVisibleproperty in your component's code-behind or@codeblock. - Update any logic that shows/hides the mask to set
IsMaskVisibletotrueorfalseas appropriate. - Remove any other usage of inline
style="display: none"for.search-dialog-maskin this file.
Link issues
fixes #583
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
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:
.bb-g-searchclass for the global search container with flex layout, custom paddings, border, transitions, and placeholder styling.search-dialog-maskinto a fixed, centered overlay with translucent background and hide it by default usingd-nonevisually-hiddenand reveal both the box and mask during initialization in the JS modulevisually-hiddenon the search container andd-noneon the mask