mirror of
https://github.com/MarekWo/mc-webui.git
synced 2026-08-02 23:13:08 +02:00
fix(dm): prevent dropdown close on mouse hover, ensure name after select
- Prevent mousedown on dropdown from stealing focus (which closed the dropdown before click could register on desktop) - After selecting from dropdown, override search input with the known name to guarantee correct display even if prefix match fails Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+13
-5
@@ -189,7 +189,13 @@ function setupEventListeners() {
|
||||
contactDropdown.style.display = 'block';
|
||||
});
|
||||
|
||||
document.addEventListener('click', (e) => {
|
||||
// Prevent dropdown mousedown from stealing focus/closing dropdown
|
||||
contactDropdown.addEventListener('mousedown', (e) => {
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
// Close dropdown when clicking outside the wrapper
|
||||
document.addEventListener('mousedown', (e) => {
|
||||
if (searchWrapper && !searchWrapper.contains(e.target)) {
|
||||
contactDropdown.style.display = 'none';
|
||||
}
|
||||
@@ -452,12 +458,14 @@ function createDropdownItem(name, conversationId, isUnread, contact) {
|
||||
/**
|
||||
* Handle selection from the searchable dropdown.
|
||||
*/
|
||||
function selectConversationFromDropdown(conversationId, name) {
|
||||
const input = document.getElementById('dmContactSearchInput');
|
||||
async function selectConversationFromDropdown(conversationId, name) {
|
||||
const dropdown = document.getElementById('dmContactDropdown');
|
||||
if (input) input.value = displayName(name);
|
||||
if (dropdown) dropdown.style.display = 'none';
|
||||
selectConversation(conversationId);
|
||||
await selectConversation(conversationId);
|
||||
// Override search input with the known name (selectConversation may not resolve it)
|
||||
const input = document.getElementById('dmContactSearchInput');
|
||||
if (input && name) input.value = displayName(name);
|
||||
if (name) currentRecipient = name;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user