Skip to content

Commit 068a28a

Browse files
committed
fix: ui remove pagination
1 parent ace57d8 commit 068a28a

File tree

1 file changed

+42
-2
lines changed

1 file changed

+42
-2
lines changed

src/components/recorder/RightSidePanel.tsx

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,46 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
415415
}, [stopGetList, resetListState]);
416416

417417
const stopCaptureAndEmitGetListSettings = useCallback(() => {
418+
if (autoDetectedPagination?.selector) {
419+
const iframeElement = document.querySelector('#browser-window iframe') as HTMLIFrameElement;
420+
if (iframeElement?.contentDocument) {
421+
try {
422+
function evaluateSelector(selector: string, doc: Document): Element[] {
423+
if (selector.startsWith('//') || selector.startsWith('(//')) {
424+
try {
425+
const result = doc.evaluate(selector, doc, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
426+
const elements: Element[] = [];
427+
for (let i = 0; i < result.snapshotLength; i++) {
428+
const node = result.snapshotItem(i);
429+
if (node && node.nodeType === Node.ELEMENT_NODE) {
430+
elements.push(node as Element);
431+
}
432+
}
433+
return elements;
434+
} catch (err) {
435+
return [];
436+
}
437+
} else {
438+
try {
439+
return Array.from(doc.querySelectorAll(selector));
440+
} catch (err) {
441+
return [];
442+
}
443+
}
444+
}
445+
446+
const elements = evaluateSelector(autoDetectedPagination.selector, iframeElement.contentDocument);
447+
elements.forEach((el: Element) => {
448+
(el as HTMLElement).style.outline = '';
449+
(el as HTMLElement).style.outlineOffset = '';
450+
(el as HTMLElement).style.zIndex = '';
451+
});
452+
} catch (error) {
453+
console.error('Error removing pagination highlight on completion:', error);
454+
}
455+
}
456+
}
457+
418458
const latestListStep = getLatestListStep(browserSteps);
419459
if (latestListStep) {
420460
extractDataClientSide(latestListStep.listSelector!, latestListStep.fields, latestListStep.id);
@@ -423,7 +463,7 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
423463
...currentWorkflowActionsState,
424464
hasScrapeListAction: true
425465
});
426-
466+
427467
emitActionForStep(latestListStep);
428468

429469
handleStopGetList();
@@ -441,7 +481,7 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
441481
onFinishCapture();
442482
clientSelectorGenerator.cleanup();
443483
}
444-
}, [socket, notify, handleStopGetList, resetInterpretationLog, finishAction, onFinishCapture, t, browserSteps, extractDataClientSide, setCurrentWorkflowActionsState, currentWorkflowActionsState, emitActionForStep]);
484+
}, [socket, notify, handleStopGetList, resetInterpretationLog, finishAction, onFinishCapture, t, browserSteps, extractDataClientSide, setCurrentWorkflowActionsState, currentWorkflowActionsState, emitActionForStep, autoDetectedPagination]);
445485

446486
const getLatestListStep = (steps: BrowserStep[]) => {
447487
const listSteps = steps.filter(step => step.type === 'list');

0 commit comments

Comments
 (0)