mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-05-07 03:32:18 +08:00
Merge pull request #2731 from zkjqd/fix/slash-menu-click
Fix the issue where the shortcut command in the input box cannot be clicked to select events
This commit is contained in:
@@ -507,21 +507,29 @@ function renderSlashItems() {
|
||||
`<span class="desc">${escapeHtml(c.desc)}</span></div>`
|
||||
).join('');
|
||||
|
||||
slashMenu.querySelectorAll('.slash-menu-item').forEach(el => {
|
||||
el.addEventListener('mouseenter', () => {
|
||||
slashActiveIdx = parseInt(el.dataset.idx);
|
||||
renderSlashItems();
|
||||
});
|
||||
el.addEventListener('mousedown', (e) => {
|
||||
e.preventDefault();
|
||||
selectSlashCommand(parseInt(el.dataset.idx));
|
||||
});
|
||||
});
|
||||
|
||||
const activeEl = slashMenu.querySelector('.slash-menu-item.active');
|
||||
if (activeEl) activeEl.scrollIntoView({ block: 'nearest' });
|
||||
}
|
||||
|
||||
// Delegated events on the persistent slashMenu container (not destroyed by innerHTML)
|
||||
slashMenu.addEventListener('mouseover', (e) => {
|
||||
const item = e.target.closest('.slash-menu-item');
|
||||
if (!item) return;
|
||||
const idx = parseInt(item.dataset.idx);
|
||||
if (idx === slashActiveIdx) return;
|
||||
slashActiveIdx = idx;
|
||||
slashMenu.querySelectorAll('.slash-menu-item').forEach(el => {
|
||||
el.classList.toggle('active', parseInt(el.dataset.idx) === idx);
|
||||
});
|
||||
});
|
||||
|
||||
slashMenu.addEventListener('mousedown', (e) => {
|
||||
const item = e.target.closest('.slash-menu-item');
|
||||
if (!item) return;
|
||||
e.preventDefault();
|
||||
selectSlashCommand(parseInt(item.dataset.idx));
|
||||
});
|
||||
|
||||
function selectSlashCommand(idx) {
|
||||
if (idx < 0 || idx >= slashFiltered.length) return;
|
||||
const chosen = slashFiltered[idx].cmd;
|
||||
|
||||
Reference in New Issue
Block a user