mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
typeahead: Ignore mouse position for selection until it's moved.
Added a property `mouse_moved_since_typeahead` to the typeahead class which tracks whether the mouse has been moved since the typeahead menu appeared. The hovered over menu item is highlighted on `mouseenter` only if `mouseMoved` is true. Otherwise, the cursor is hidden temporarily. Code substantially reorganized by tabbott. Fixes: #21018.
This commit is contained in:
@@ -491,6 +491,11 @@ class CommonUtils {
|
||||
`//*[@class="typeahead dropdown-menu" and contains(@style, "display: block")]//li[contains(normalize-space(), "${item}")]//a`,
|
||||
{visible: true},
|
||||
);
|
||||
const entry_x = (await entry?.boundingBox())?.x;
|
||||
const entry_y = (await entry?.boundingBox())?.y;
|
||||
if (entry_x && entry_y) {
|
||||
await page.mouse.move(entry_x, entry_y);
|
||||
}
|
||||
await page.evaluate((entry) => {
|
||||
entry.click();
|
||||
}, entry);
|
||||
|
||||
@@ -229,6 +229,9 @@ async function get_suggestions(page: Page, str: string): Promise<void> {
|
||||
async function select_from_suggestions(page: Page, item: string): Promise<void> {
|
||||
await page.evaluate((item: string) => {
|
||||
const tah = $(".create_default_stream").data().typeahead;
|
||||
tah.mousemove({
|
||||
currentTarget: $(`.typeahead:visible li:contains("${CSS.escape(item)}")`)[0],
|
||||
});
|
||||
tah.mouseenter({
|
||||
currentTarget: $(`.typeahead:visible li:contains("${CSS.escape(item)}")`)[0],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user