Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Fix - disable voice button in search box when option is off

supporteb7cef949199
diff --git a/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/SearchBox/Default.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/SearchBox/Default.cshtml
index afd3e5d03..55e6bfad7 100644
--- a/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/SearchBox/Default.cshtml
+++ b/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/SearchBox/Default.cshtml
@@ -24,22 +24,25 @@
@await Component.InvokeAsync("Widget", new { widgetZone = "searchbox_before_search_button" })
<div class="input-group-append">
- <button id="voiceSearchButton"
- v-if="searchbox.allowed"
- @@touchstart="searchbox.recording = true"
- @@touchcancel="searchbox.recording = false; $root.$emit('bv::hide::tooltip')"
- @@touchend="searchbox.recording = false; $root.$emit('bv::hide::tooltip')"
- @@mousedown="searchbox.recording = true"
- @@mouseup="searchbox.recording = false"
- @@mouseleave="searchbox.recording = false"
- v-b-tooltip.hover.bottom :title="searchbox.micMessage" ref="micBtn" type="button" v-bind:class="[{ focus: searchbox.recording }, 'btn btn-outline-secondary search-button btn-mic']">
- <template v-if="searchbox.recording">
- <span class="icons icon-microphone"></span>
- </template>
- <template v-else>
- <span class="icons icon-microphone"></span>
- </template>
- </button>
+ @if (Model.VoiceNavigatioEnabled)
+ {
+ <button id="voiceSearchButton"
+ v-if="searchbox.allowed"
+ @@touchstart="searchbox.recording = true"
+ @@touchcancel="searchbox.recording = false; $root.$emit('bv::hide::tooltip')"
+ @@touchend="searchbox.recording = false; $root.$emit('bv::hide::tooltip')"
+ @@mousedown="searchbox.recording = true"
+ @@mouseup="searchbox.recording = false"
+ @@mouseleave="searchbox.recording = false"
+ v-b-tooltip.hover.bottom :title="searchbox.micMessage" ref="micBtn" type="button" v-bind:class="[{ focus: searchbox.recording }, 'btn btn-outline-secondary search-button btn-mic']">
+ <template v-if="searchbox.recording">
+ <span class="icons icon-microphone"></span>
+ </template>
+ <template v-else>
+ <span class="icons icon-microphone"></span>
+ </template>
+ </button>
+ }
<button type="submit" class="btn btn-outline-secondary search-box-button search-button float-sm-right d-inline-flex align-items-center">
<span class="sr-only">@Loc["Search.SearchBox.Tooltip"]</span>
<span class="icons icon-magnifier"></span>
diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetSearchBoxHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetSearchBoxHandler.cs
index 64b38ee4e..11da08c0f 100644
--- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetSearchBoxHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetSearchBoxHandler.cs
@@ -2,6 +2,7 @@
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Domain.Catalog;
using Grand.Domain.Customers;
+using Grand.Domain.Stores;
using Grand.Infrastructure.Caching;
using Grand.Web.Events.Cache;
using Grand.Web.Features.Models.Catalog;
@@ -17,17 +18,19 @@ namespace Grand.Web.Features.Handlers.Catalog
private readonly ICategoryService _categoryService;
private readonly ITranslationService _translationService;
private readonly CatalogSettings _catalogSettings;
-
+ private readonly StoreInformationSettings _storeInformationSettings;
public GetSearchBoxHandler(
ICacheBase cacheBase,
ICategoryService categoryService,
ITranslationService translationService,
- CatalogSettings catalogSettings)
+ CatalogSettings catalogSettings,
+ StoreInformationSettings storeInformationSettings)
{
_cacheBase = cacheBase;
_categoryService = categoryService;
_translationService = translationService;
_catalogSettings = catalogSettings;
+ _storeInformationSettings = storeInformationSettings;
}
public async Task<SearchBoxModel> Handle(GetSearchBox request, CancellationToken cancellationToken)
@@ -52,7 +55,8 @@ namespace Grand.Web.Features.Handlers.Catalog
AutoCompleteEnabled = _catalogSettings.ProductSearchAutoCompleteEnabled,
ShowProductImagesInSearchAutoComplete = _catalogSettings.ShowProductImagesInSearchAutoComplete,
SearchTermMinimumLength = _catalogSettings.ProductSearchTermMinimumLength,
- AvailableCategories = availableCategories
+ AvailableCategories = availableCategories,
+ VoiceNavigatioEnabled = _storeInformationSettings.VoiceNavigation
};
return model;
diff --git a/src/Web/Grand.Web/Models/Catalog/SearchBoxModel.cs b/src/Web/Grand.Web/Models/Catalog/SearchBoxModel.cs
index b74e039d0..f4fdb8acc 100644
--- a/src/Web/Grand.Web/Models/Catalog/SearchBoxModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/SearchBoxModel.cs
@@ -10,6 +10,8 @@ namespace Grand.Web.Models.Catalog
AvailableCategories = new List<SelectListItem>();
}
public bool AutoCompleteEnabled { get; set; }
+
+ public bool VoiceNavigatioEnabled { get; set; }
public bool ShowProductImagesInSearchAutoComplete { get; set; }
public int SearchTermMinimumLength { get; set; }
public string SearchCategoryId { get; set; }
diff --git a/src/Web/Grand.Web/Views/Shared/Components/SearchBox/Default.cshtml b/src/Web/Grand.Web/Views/Shared/Components/SearchBox/Default.cshtml
index 0a67eed5d..57897b2a9 100644
--- a/src/Web/Grand.Web/Views/Shared/Components/SearchBox/Default.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Components/SearchBox/Default.cshtml
@@ -24,22 +24,25 @@
@await Component.InvokeAsync("Widget", new { widgetZone = "searchbox_before_search_button" })
<div class="input-group-append">
- <button id="voiceSearchButton"
- v-if="searchbox.allowed"
- @@touchstart="searchbox.recording = true"
- @@touchcancel="searchbox.recording = false; $root.$emit('bv::hide::tooltip')"
- @@touchend="searchbox.recording = false; $root.$emit('bv::hide::tooltip')"
- @@mousedown="searchbox.recording = true"
- @@mouseup="searchbox.recording = false"
- @@mouseleave="searchbox.recording = false"
- v-b-tooltip.hover.bottom :title="searchbox.micMessage" ref="micBtn" type="button" v-bind:class="[{ focus: searchbox.recording }, 'btn btn-link']">
- <template v-if="searchbox.recording">
- <b-icon icon="mic" variant="info"></b-icon>
- </template>
- <template v-else>
- <b-icon icon="mic-mute" variant="danger"></b-icon>
- </template>
- </button>
+ @if (Model.VoiceNavigatioEnabled)
+ {
+ <button id="voiceSearchButton"
+ v-if="searchbox.allowed"
+ @@touchstart="searchbox.recording = true"
+ @@touchcancel="searchbox.recording = false; $root.$emit('bv::hide::tooltip')"
+ @@touchend="searchbox.recording = false; $root.$emit('bv::hide::tooltip')"
+ @@mousedown="searchbox.recording = true"
+ @@mouseup="searchbox.recording = false"
+ @@mouseleave="searchbox.recording = false"
+ v-b-tooltip.hover.bottom :title="searchbox.micMessage" ref="micBtn" type="button" v-bind:class="[{ focus: searchbox.recording }, 'btn btn-link']">
+ <template v-if="searchbox.recording">
+ <b-icon icon="mic" variant="info"></b-icon>
+ </template>
+ <template v-else>
+ <b-icon icon="mic-mute" variant="danger"></b-icon>
+ </template>
+ </button>
+ }
<button type="submit" class="btn btn-link search-box-button float-sm-right d-inline-flex align-items-center">
<span class="sr-only">@Loc["Search.SearchBox.Tooltip"]</span>
<b-icon icon="search"></b-icon>