provide better support for AllowTextInput on Search component
This commit is contained in:
		| @ -8,34 +8,26 @@ | ||||
|  | ||||
| @if (_searchResultsPage != null) | ||||
| { | ||||
|     @if (AllowTextInput) | ||||
|     { | ||||
|         <span class="app-search @CssClass"> | ||||
|             <form method="post" class="app-form-inline" @formname="@($"SearchForm")" @onsubmit="@PerformSearch" data-enhance> | ||||
|                 <input type="hidden" name="@Constants.RequestVerificationToken" value="@SiteState.AntiForgeryToken" /> | ||||
|     <span class="@_defaultCssClass @CssClass"> | ||||
|         <form method="post" class="app-form-inline" @formname="@($"SearchForm")" @onsubmit="@PerformSearch" data-enhance> | ||||
|             <input type="hidden" name="@Constants.RequestVerificationToken" value="@SiteState.AntiForgeryToken" /> | ||||
|             @if (AllowTextInput) | ||||
|             { | ||||
|                 <input type="text" name="keywords" maxlength="50" | ||||
|                         class="form-control d-inline-block pe-5 shadow-none" | ||||
|                         @bind="_keywords" | ||||
|                         placeholder="@Localizer["SearchPlaceHolder"]" | ||||
|                         aria-label="Search" /> | ||||
|                 <button type="submit" class="btn btn-search"> | ||||
|                     <span class="oi oi-magnifying-glass align-middle"></span> | ||||
|                 </button> | ||||
|             </form> | ||||
|         </span> | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         <form method="post" class="app-form-inline" @formname="@($"SearchForm")" @onsubmit="@PerformSearch" data-enhance> | ||||
|             <input type="hidden" name="@Constants.RequestVerificationToken" value="@SiteState.AntiForgeryToken" /> | ||||
|             <button type="submit" class="btn btn-primary"> | ||||
|             } | ||||
|             <button type="submit" class="btn btn-search"> | ||||
|                 <span class="oi oi-magnifying-glass align-middle"></span> | ||||
|             </button> | ||||
|         </form> | ||||
|     } | ||||
|     </span> | ||||
| } | ||||
|  | ||||
| @code { | ||||
|     private string _defaultCssClass; | ||||
|     private Page _searchResultsPage; | ||||
|     private string _keywords = ""; | ||||
|  | ||||
| @ -43,7 +35,7 @@ | ||||
|     public string CssClass { get; set; } | ||||
|  | ||||
|     [Parameter] | ||||
|     public bool AllowTextInput { get; set; } = true; // setting to false will display only the search icon button - not the textbox  | ||||
|     public bool AllowTextInput { get; set; } = true; // setting to false will display only the search icon button - not the textbox | ||||
|  | ||||
|     [Parameter] | ||||
|     public string SearchResultPagePath { get; set; } = "search"; // setting to "" will disable search | ||||
| @ -58,6 +50,7 @@ | ||||
|     { | ||||
|         if (bool.Parse(SettingService.GetSetting(PageState.Site.Settings, "Search_Enabled", "True"))) | ||||
|         { | ||||
|             _defaultCssClass = (AllowTextInput) ? "app-search" : "app-search-noinput"; | ||||
|             if (!string.IsNullOrEmpty(SearchResultPagePath)) | ||||
|             { | ||||
|                 _searchResultsPage = PageState.Pages.FirstOrDefault(i => i.Path == SearchResultPagePath); | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 sbwalker
					sbwalker