Merge pull request #23 from Shchoholiev/bug/SA-227-Fix-suggestions

Sa-227 Fix suggestions
This commit is contained in:
Mykhailo Bilodid 2023-12-13 02:09:16 +02:00 committed by GitHub
commit 5848fb452b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 52 additions and 21 deletions

View File

@ -72,34 +72,34 @@
</ul> </ul>
</div>
<div class="possible_options">
</div> @if (Suggestion.Count != 0)
{
<div class="tite_options">Several possible options</div>
<div class="possible_options"> <div class="options">
@if (Suggestion.Count != 0)
{
<div class="tite_options">Several possible options</div>
<div class="options">
@foreach (var item in Suggestion) @foreach (var item in Suggestion)
{ {
<div @onclick="() => ClickOption(item)" class="topic_options"> <div @onclick="() => ClickOption(item)" class="topic_options">
@item @item
</div> </div>
} }
</div>
}
</div>
</div>
}
</div>
<div class="chat_input"> <div class="chat_input">
@ -127,9 +127,24 @@
function myJavaScriptFunction(wishlistId) { function myJavaScriptFunction(wishlistId) {
UpdateMenu(wishlistId); UpdateMenu(wishlistId);
} }
document.getElementById('button_open').addEventListener('click', changetyle); document.getElementById('button_open').addEventListener('click', changetyle);
</script> </script>
<script>
function myJavaScriptHeight() {
var myDiv = document.querySelector('.possible_options');
var posth = document.querySelector('.chat_message');
var height = myDiv.offsetHeight*0.063
posth.style.height = 'calc(100% - ' + (8.5 + height) + 'em)';
}
document.getElementById('button_open').addEventListener('click', myJavaScriptHeight);
</script>
@code { @code {
[Parameter] public string chatId { get; set; } [Parameter] public string chatId { get; set; }
@ -159,7 +174,9 @@
protected override async Task OnAfterRenderAsync(bool firstRender) protected override async Task OnAfterRenderAsync(bool firstRender)
{ {
await JSRuntime.InvokeVoidAsync("myJavaScriptHeight");
await JSRuntime.InvokeVoidAsync("scrollToBottom", chatMessageRef); await JSRuntime.InvokeVoidAsync("scrollToBottom", chatMessageRef);
} }
private async Task UpdateSideMenu(string wishlistId) private async Task UpdateSideMenu(string wishlistId)
@ -171,6 +188,7 @@
private void ClickOption(string item) private void ClickOption(string item)
{ {
inputValue = item; inputValue = item;
AddNewMessage(inputValue);
} }
} }

View File

@ -210,8 +210,9 @@ public partial class Chat : ComponentBase
Products.Add(input); Products.Add(input);
} else if(sseEvent.Event == SearchEventType.Suggestion){ } else if(sseEvent.Event == SearchEventType.Suggestion){
if(Suggestion.Count<6){
Suggestion.Add(result); Suggestion.Add(result);
}
} }
} }

View File

@ -84,6 +84,18 @@
margin-left: 25%; margin-left: 25%;
width: 50%; width: 50%;
border-radius: 0.6em; border-radius: 0.6em;
@media screen and (max-width: 750px) {
margin-left: 15%;
width: 70%;
}
@media screen and (max-width: 480px) {
margin-left: 2%;
width: 96%;
}
} }
.tite_options { .tite_options {
@ -105,7 +117,7 @@
border: 0.09em solid; border: 0.09em solid;
border-color: #009FFF; border-color: #009FFF;
border-radius: 0.6em; border-radius: 0.6em;
margin: 0em 0.6em; margin: 0.2em 0.2em;
flex: 1; flex: 1;
text-align: center; text-align: center;
cursor: pointer; cursor: pointer;