mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 06:39:48 +00:00
Autofocus alert cancel button
This commit is contained in:
parent
f746eff4ca
commit
c579e1a6e0
@ -86,7 +86,7 @@ class ResponseHistoryDropdown extends PureComponent {
|
||||
<Dropdown ref={this._setDropdownRef}
|
||||
key={activeResponse ? activeResponse._id : 'n/a'} {...extraProps}>
|
||||
<DropdownButton className="btn btn--super-compact tall" title="Response history">
|
||||
{!isLatestResponseActive ? <i className="fa fa-thumb-tack"/> : null}
|
||||
{!isLatestResponseActive ? <i className="fa fa-thumb-tack"/> : <i className="fa fa-clock-o"/>}
|
||||
<i className="fa fa-caret-down"/>
|
||||
</DropdownButton>
|
||||
<DropdownDivider>Response History</DropdownDivider>
|
||||
|
@ -30,12 +30,25 @@ class AlertModal extends PureComponent {
|
||||
this.modal.hide();
|
||||
}
|
||||
|
||||
setCancelRef (n) {
|
||||
this._cancel = n;
|
||||
}
|
||||
|
||||
setOkRef (n) {
|
||||
this._ok = n;
|
||||
}
|
||||
|
||||
show (options = {}) {
|
||||
const {title, message, addCancel} = options;
|
||||
this.setState({title, message, addCancel});
|
||||
|
||||
this.modal.show();
|
||||
|
||||
// Need to do this after render because modal focuses itself too
|
||||
setTimeout(() => {
|
||||
this._cancel && this._cancel.focus();
|
||||
}, 100);
|
||||
|
||||
return new Promise(resolve => {
|
||||
this._okCallback = resolve;
|
||||
});
|
||||
@ -52,8 +65,12 @@ class AlertModal extends PureComponent {
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<div>
|
||||
{addCancel ? <button className="btn" onClick={this.hide}>Cancel</button> : null}
|
||||
<button className="btn" onClick={this._handleOk}>
|
||||
{addCancel ? (
|
||||
<button className="btn" ref={this.setCancelRef} onClick={this.hide}>
|
||||
Cancel
|
||||
</button>
|
||||
) : null}
|
||||
<button className="btn" ref={this.setOkRef} onClick={this._handleOk}>
|
||||
Ok
|
||||
</button>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user