diff --git a/libs/remix-ui/modal-dialog/src/lib/remix-ui-modal-dialog.tsx b/libs/remix-ui/modal-dialog/src/lib/remix-ui-modal-dialog.tsx index f60309c24e..66330349b0 100644 --- a/libs/remix-ui/modal-dialog/src/lib/remix-ui-modal-dialog.tsx +++ b/libs/remix-ui/modal-dialog/src/lib/remix-ui-modal-dialog.tsx @@ -103,7 +103,8 @@ export const ModalDialog = (props: ModalDialogProps) => { onClick={() => { if (props.validation && !props.validation.valid) return if (props.okFn) props.okFn() - handleHide() + if (props.donotHideOnOkClick) calledHideFunctionOnce.current = false + else handleHide() }} > {props.okLabel ? props.okLabel : 'OK'} diff --git a/libs/remix-ui/modal-dialog/src/lib/types/index.ts b/libs/remix-ui/modal-dialog/src/lib/types/index.ts index e469bffc61..0c96017bac 100644 --- a/libs/remix-ui/modal-dialog/src/lib/types/index.ts +++ b/libs/remix-ui/modal-dialog/src/lib/types/index.ts @@ -13,6 +13,7 @@ export interface ModalDialogProps { message?: string | JSX.Element, okLabel?: string | JSX.Element, okFn?: (value?:any) => void, + donotHideOnOkClick?: boolean, cancelLabel?: string | JSX.Element, cancelFn?: () => void, modalClass?: string, diff --git a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx index afdab1cc68..7100b1dbf8 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx @@ -281,6 +281,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { 'New configuration file', `The file "${configFilePathInput.current.value}" you entered does not exist. Do you want to create a new one?`, 'Create', async () => await createNewConfigFile(), + false, 'Cancel', () => { setShowFilePathInput(false) @@ -580,6 +581,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { promptMessage('URL'), 'OK', addCustomCompiler, + false, 'Cancel', () => {} ) diff --git a/libs/remix-ui/solidity-compiler/src/lib/contract-selection.tsx b/libs/remix-ui/solidity-compiler/src/lib/contract-selection.tsx index e245ea8b62..02c04893be 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/contract-selection.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/contract-selection.tsx @@ -190,7 +190,7 @@ export const ContractSelection = (props: ContractSelectionProps) => { _paq.push(['trackEvent', 'compiler', 'compilerDetails', 'download']) saveAs(new Blob([JSON.stringify(contractProperties, null, '\t')]), `${selectedContract}_compData.json`) } - modal(selectedContract, log, 'Download', downloadFn, 'Close', null) + modal(selectedContract, log, 'Download', downloadFn, true, 'Close', null) } const copyBytecode = () => { diff --git a/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx b/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx index 328797acf3..6277443121 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx @@ -27,6 +27,7 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => { message: null, okLabel: '', okFn: () => { }, + donotHideOnOkClick: false, cancelLabel: '', cancelFn: () => { }, handleHide: null @@ -131,7 +132,7 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => { api.setCompilerParameters({ version: value }) } - const modal = async (title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void) => { + const modal = async (title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, donotHideOnOkClick: boolean, cancelLabel?: string, cancelFn?: () => void) => { await setState(prevState => { return { ...prevState, @@ -142,6 +143,7 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => { title, okLabel, okFn, + donotHideOnOkClick, cancelLabel, cancelFn } @@ -190,7 +192,7 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => { <> {compileErrors[currentFile].error && } - {compileErrors[currentFile].error && (compileErrors[currentFile].error.mode === 'panic') && modal('Error', panicMessage(compileErrors[currentFile].error.formattedMessage), 'Close', null)} + {compileErrors[currentFile].error && (compileErrors[currentFile].error.mode === 'panic') && modal('Error', panicMessage(compileErrors[currentFile].error.formattedMessage), 'Close', null, false)} {compileErrors[currentFile].errors && compileErrors[currentFile].errors.length && compileErrors[currentFile].errors.map((err, index) => { if (hideWarnings) { if (err.severity !== 'warning') { @@ -212,6 +214,7 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => { hide={state.modal.hide} okLabel={state.modal.okLabel} okFn={state.modal.okFn} + donotHideOnOkClick={state.modal.donotHideOnOkClick} cancelLabel={state.modal.cancelLabel} cancelFn={state.modal.cancelFn} handleHide={handleHideModal}> diff --git a/libs/remix-ui/solidity-compiler/src/lib/types/index.ts b/libs/remix-ui/solidity-compiler/src/lib/types/index.ts index 7e14b71973..848596f5e0 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/types/index.ts +++ b/libs/remix-ui/solidity-compiler/src/lib/types/index.ts @@ -14,7 +14,7 @@ export interface CompilerContainerProps { isFoundryProject: boolean, workspaceName: string, tooltip: (message: string | JSX.Element) => void, - modal: (title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void) => void, + modal: (title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, donotHideOnOkClick?: boolean, cancelLabel?: string, cancelFn?: () => void) => void, compiledFileName: string, updateCurrentVersion: any, configurationSettings: ConfigurationSettings, @@ -26,7 +26,7 @@ export interface ContractSelectionProps { compiledFileName: string, contractList: { file: string, name: string }[], compilerInput: Record - modal: (title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void) => void, + modal: (title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, donotHideOnOkClick?: boolean, cancelLabel?: string, cancelFn?: () => void) => void, contractsDetails: Record }