fix: handle attribute selection in getList
This commit is contained in:
@@ -203,27 +203,32 @@ export const BrowserWindow = () => {
|
|||||||
setCurrentListId(Date.now());
|
setCurrentListId(Date.now());
|
||||||
setFields({});
|
setFields({});
|
||||||
} else if (getList === true && listSelector && currentListId) {
|
} else if (getList === true && listSelector && currentListId) {
|
||||||
|
const attribute = options[0].value;
|
||||||
|
const data = attribute === 'href' ? highlighterData.elementInfo?.url || '' :
|
||||||
|
attribute === 'src' ? highlighterData.elementInfo?.imageUrl || '' :
|
||||||
|
highlighterData.elementInfo?.innerText || '';
|
||||||
// Add fields to the list
|
// Add fields to the list
|
||||||
if (options.length === 1) {
|
if (options.length === 1) {
|
||||||
const attribute = options[0].value;
|
const attribute = options[0].value;
|
||||||
const data = attribute === 'href' ? highlighterData.elementInfo?.url || '' :
|
const newField: TextStep = {
|
||||||
attribute === 'src' ? highlighterData.elementInfo?.imageUrl || '' :
|
id: Date.now(),
|
||||||
highlighterData.elementInfo?.innerText || ''; const newField: TextStep = {
|
type: 'text',
|
||||||
id: Date.now(),
|
label: `Label ${Object.keys(fields).length + 1}`,
|
||||||
type: 'text',
|
data: data,
|
||||||
label: `Label ${Object.keys(fields).length + 1}`,
|
selectorObj: {
|
||||||
data: data,
|
selector: highlighterData.selector,
|
||||||
selectorObj: {
|
tag: highlighterData.elementInfo?.tagName,
|
||||||
selector: highlighterData.selector,
|
attribute
|
||||||
tag: highlighterData.elementInfo?.tagName,
|
}
|
||||||
attribute
|
};
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
setFields(prevFields => ({
|
setFields(prevFields => {
|
||||||
...prevFields,
|
const updatedFields = {
|
||||||
[newField.label]: newField
|
...prevFields,
|
||||||
}));
|
[newField.label]: newField
|
||||||
|
};
|
||||||
|
return updatedFields;
|
||||||
|
});
|
||||||
|
|
||||||
if (listSelector) {
|
if (listSelector) {
|
||||||
addListStep(listSelector, { ...fields, [newField.label]: newField }, currentListId, { type: '', selector: paginationSelector });
|
addListStep(listSelector, { ...fields, [newField.label]: newField }, currentListId, { type: '', selector: paginationSelector });
|
||||||
|
|||||||
Reference in New Issue
Block a user