-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
issues_1189_1190: Fixed switching between locator types and validation icon #1202
Conversation
@@ -1,22 +1,20 @@ | |||
import React from "react"; | |||
import { Spin, Tooltip } from "antd"; | |||
import Icon from "@ant-design/icons"; | |||
import CheckedEdited from "../assets/checked-edited.svg"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please, delete svg file as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
newValue.locator.customXpath = locator; | ||
locatorType !== LocatorType.cssSelector | ||
? (newValue.locator.customXpath = locator) | ||
: (newValue.locator.cssSelector = locator); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please, use if
. ternary looks confusing here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or you can write smth like following:
newValue.locator = locatorType !== LocatorType.cssSelector
? { ...newValue.locator, customXpath: locator }
: { ...newValue.locator, cssSelector: locator };
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
const nodeSnapshot = document.evaluate(xPath, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); | ||
const length = nodeSnapshot.snapshotLength; | ||
const foundElement = nodeSnapshot.snapshotItem(0) as Element; | ||
const foundElements = document.querySelectorAll(selector); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's use querySelector
, since there's no need in ...All
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
value === locatorType ? form.setFieldValue("locator", locatorField) : form.setFieldValue("locator", ""); | ||
} else { | ||
form.setFieldValue("locator", getLocator(locator, value)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there if
's need to be refactored. for example, extract them to functions.
also, code will be less verbose if you write form.setFieldValue("locator", result)
once in the end, and only calculate result
value above
|
||
const onFieldsChange = async (changedValues: any) => { | ||
const [changedValue] = changedValues; | ||
const isLocatorTypeChanged = changedValue?.name[0] === "locatorType"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the type of changedValues
? Is there always will be inly one value? Using index can be unstable for cases when there are more that one item in array
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for code!
No description provided.