diff --git a/src/components/prompt/prompt.jsx b/src/components/prompt/prompt.jsx index 1c75655090191ca8d0a27e5227315c18295cd119..d60af1f3446bea935c7a15beb6edc638eb4370d8 100644 --- a/src/components/prompt/prompt.jsx +++ b/src/components/prompt/prompt.jsx @@ -47,9 +47,10 @@ const PromptComponent = props => ( <input autoFocus className={styles.variableNameTextInput} + defaultValue={props.defaultValue} name={props.label} - placeholder={props.placeholder} onChange={props.onChange} + onFocus={props.onFocus} onKeyPress={props.onKeyPress} /> </Box> @@ -137,16 +138,17 @@ const PromptComponent = props => ( PromptComponent.propTypes = { canAddCloudVariable: PropTypes.bool.isRequired, cloudSelected: PropTypes.bool.isRequired, + defaultValue: PropTypes.string, globalSelected: PropTypes.bool.isRequired, isStage: PropTypes.bool.isRequired, label: PropTypes.string.isRequired, onCancel: PropTypes.func.isRequired, onChange: PropTypes.func.isRequired, onCloudVarOptionChange: PropTypes.func, + onFocus: PropTypes.func.isRequired, onKeyPress: PropTypes.func.isRequired, onOk: PropTypes.func.isRequired, onScopeOptionSelection: PropTypes.func.isRequired, - placeholder: PropTypes.string, showCloudOption: PropTypes.bool.isRequired, showVariableOptions: PropTypes.bool.isRequired, title: PropTypes.string.isRequired diff --git a/src/containers/blocks.jsx b/src/containers/blocks.jsx index 17850ed98106a32cb28dff983d12a1fcc2080962..80cc87167de0b556857654e886743f59dfbfb93d 100644 --- a/src/containers/blocks.jsx +++ b/src/containers/blocks.jsx @@ -460,9 +460,9 @@ class Blocks extends React.Component { /> {this.state.prompt ? ( <Prompt + defaultValue={this.state.prompt.defaultValue} isStage={vm.runtime.getEditingTarget().isStage} label={this.state.prompt.message} - placeholder={this.state.prompt.defaultValue} showCloudOption={this.state.prompt.showCloudOption} showVariableOptions={this.state.prompt.showVariableOptions} title={this.state.prompt.title} diff --git a/src/containers/prompt.jsx b/src/containers/prompt.jsx index 27b14dcfacb84ab867b02e9e29056f46fa0612d9..2c06a3e6ccb3b053a7121455486f2e74a5fbef1a 100644 --- a/src/containers/prompt.jsx +++ b/src/containers/prompt.jsx @@ -25,6 +25,9 @@ class Prompt extends React.Component { handleKeyPress (event) { if (event.key === 'Enter') this.handleOk(); } + handleFocus (event) { + event.target.select(); + } handleOk () { this.props.onOk(this.state.inputValue, { scope: this.state.globalSelected ? 'global' : 'local', @@ -54,16 +57,17 @@ class Prompt extends React.Component { <PromptComponent canAddCloudVariable={this.state.canAddCloudVariable} cloudSelected={this.state.cloudSelected} + defaultValue={this.props.defaultValue} globalSelected={this.state.globalSelected} isStage={this.props.isStage} label={this.props.label} - placeholder={this.props.placeholder} showCloudOption={this.props.showCloudOption} showVariableOptions={this.props.showVariableOptions} title={this.props.title} onCancel={this.handleCancel} onChange={this.handleChange} onCloudVarOptionChange={this.handleCloudVariableOptionChange} + onFocus={this.handleFocus} onKeyPress={this.handleKeyPress} onOk={this.handleOk} onScopeOptionSelection={this.handleScopeOptionSelection} @@ -73,11 +77,11 @@ class Prompt extends React.Component { } Prompt.propTypes = { + defaultValue: PropTypes.string, isStage: PropTypes.bool.isRequired, label: PropTypes.string.isRequired, onCancel: PropTypes.func.isRequired, onOk: PropTypes.func.isRequired, - placeholder: PropTypes.string, showCloudOption: PropTypes.bool.isRequired, showVariableOptions: PropTypes.bool.isRequired, title: PropTypes.string.isRequired,