slash in input box handled

pull/1952/head
aniket-engg 3 years ago
parent d8655f3710
commit ad758cf193
  1. 22
      libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx

@ -167,15 +167,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d
const handleTestDirInput = async (e: any) => { // eslint-disable-line @typescript-eslint/no-explicit-any const handleTestDirInput = async (e: any) => { // eslint-disable-line @typescript-eslint/no-explicit-any
let testDirInput = trimTestDirInput(e.target.value) let testDirInput = trimTestDirInput(e.target.value)
testDirInput = helper.removeMultipleSlashes(testDirInput) testDirInput = helper.removeMultipleSlashes(testDirInput)
if (testDirInput !== '/') testDirInput = helper.removeTrailingSlashes(testDirInput)
setInputPathValue(testDirInput) setInputPathValue(testDirInput)
if (e.key === 'Enter') {
if (await testTabLogic.pathExists(testDirInput)) {
testTabLogic.setCurrentPath(testDirInput)
await updateForNewCurrent()
return
}
}
if (testDirInput) { if (testDirInput) {
if (testDirInput.endsWith('/') && testDirInput !== '/') { if (testDirInput.endsWith('/') && testDirInput !== '/') {
testDirInput = helper.removeTrailingSlashes(testDirInput) testDirInput = helper.removeTrailingSlashes(testDirInput)
@ -205,17 +197,6 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d
} }
} }
const handleEnter = async (e: any) => { // eslint-disable-line @typescript-eslint/no-explicit-any
let inputPath = e.target.value
inputPath = helper.removeMultipleSlashes(trimTestDirInput(inputPath))
setInputPathValue(inputPath)
if (disableCreateButton) {
if (await testTabLogic.pathExists(inputPath)) {
await setCurrentPath(inputPath)
}
}
}
const handleCreateFolder = async () => { const handleCreateFolder = async () => {
let inputPath = trimTestDirInput(inputPathValue) let inputPath = trimTestDirInput(inputPathValue)
let path = helper.removeMultipleSlashes(inputPath) let path = helper.removeMultipleSlashes(inputPath)
@ -674,8 +655,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d
title="Press 'Enter' to change the path for test files." title="Press 'Enter' to change the path for test files."
style={{ backgroundImage: "var(--primary)" }} style={{ backgroundImage: "var(--primary)" }}
onKeyDown={() => { if (inputPathValue === '/') setInputPathValue('')} } onKeyDown={() => { if (inputPathValue === '/') setInputPathValue('')} }
onKeyUp={handleTestDirInput} onChange={handleTestDirInput}
onChange={handleEnter}
onClick = {() => { if (inputPathValue === '/') setInputPathValue('')} } onClick = {() => { if (inputPathValue === '/') setInputPathValue('')} }
/> />
<button <button

Loading…
Cancel
Save