fix search on auto completion (#1544)
This commit is contained in:
@@ -2132,15 +2132,26 @@ if (window.globalObserverForDOMIncrement === undefined) {
|
||||
}
|
||||
|
||||
if (mutation.type === "childList") {
|
||||
if (mutation.target.nodeType === Node.TEXT_NODE) continue;
|
||||
const node = mutation.target;
|
||||
let changedNode = {
|
||||
targetNode: mutation.target, // TODO: for future usage, when we want to parse new elements into a tree
|
||||
targetNode: node, // TODO: for future usage, when we want to parse new elements into a tree
|
||||
};
|
||||
let newNodes = [];
|
||||
if (mutation.addedNodes && mutation.addedNodes.length > 0) {
|
||||
for (const node of mutation.addedNodes) {
|
||||
// skip the text nodes, they won't be interactable
|
||||
if (node.nodeType === Node.TEXT_NODE) continue;
|
||||
newNodes.push(node);
|
||||
if (
|
||||
node.tagName.toLowerCase() === "ul" ||
|
||||
(node.tagName.toLowerCase() === "div" &&
|
||||
node.hasAttribute("role") &&
|
||||
node.getAttribute("role").toLowerCase() === "listbox")
|
||||
) {
|
||||
newNodes.push(node);
|
||||
} else {
|
||||
if (mutation.addedNodes && mutation.addedNodes.length > 0) {
|
||||
for (const node of mutation.addedNodes) {
|
||||
// skip the text nodes, they won't be interactable
|
||||
if (node.nodeType === Node.TEXT_NODE) continue;
|
||||
newNodes.push(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (newNodes.length > 0) {
|
||||
|
||||
@@ -575,6 +575,10 @@ class IncrementalScrapePage:
|
||||
await SkyvernFrame.evaluate(frame=self.skyvern_frame.get_frame(), expression=js_script)
|
||||
|
||||
async def stop_listen_dom_increment(self) -> None:
|
||||
# check if the DOM has navigated away or refreshed
|
||||
js_script = "() => window.globalObserverForDOMIncrement === undefined"
|
||||
if await SkyvernFrame.evaluate(frame=self.skyvern_frame.get_frame(), expression=js_script):
|
||||
return
|
||||
js_script = "() => stopGlobalIncrementalObserver()"
|
||||
await SkyvernFrame.evaluate(frame=self.skyvern_frame.get_frame(), expression=js_script)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user