btc: feepicker dismissal

This commit is contained in:
ixv 2021-05-21 11:16:43 -07:00
parent 87855eadc4
commit 84f6aa33d0
2 changed files with 29 additions and 2 deletions

View File

@ -19,7 +19,27 @@ export default class FeePicker extends Component {
selected: 'mid'
}
this.select = this.select.bind(this);
this.select = this.select.bind(this);
this.clickDismiss = this.clickDismiss.bind(this);
this.setModalRef = this.setModalRef.bind(this);
}
componentDidMount() {
document.addEventListener("click", this.clickDismiss);
}
componentWillUnount() {
document.removeEventListener("click", this.clickDismiss);
}
setModalRef(n) {
this.modalRef = n;
}
clickDismiss(e) {
if (this.modalRef && !(this.modalRef.contains(e.target))){
this.props.feeDismiss();
}
}
select(which) {
@ -30,6 +50,7 @@ export default class FeePicker extends Component {
render() {
return (
<Box
ref={this.setModalRef}
position="absolute" p={4}
border="1px solid green" zIndex={10}
backgroundColor="white" borderRadius={3}

View File

@ -54,10 +54,15 @@ export default class Send extends Component {
this.initPayment = this.initPayment.bind(this);
this.checkPayee = this.checkPayee.bind(this);
this.feeSelect = this.feeSelect.bind(this);
this.feeDismiss = this.feeDismiss.bind(this);
this.toggleSignMethod = this.toggleSignMethod.bind(this);
this.setSignMethod = this.setSignMethod.bind(this);
}
feeDismiss() {
this.setState({showModal: false});
}
feeSelect(which) {
this.setState({feeValue: which});
}
@ -352,7 +357,7 @@ export default class Send extends Component {
<Icon icon="ChevronSouth"
fontSize="14px"
color="lightGray"
onClick={() => { this.setState({showModal: !this.state.showModal}); }}
onClick={() => {if (!this.state.showModal) this.setState({showModal: true}); }}
cursor="pointer"/>
</Row>
</Row>
@ -361,6 +366,7 @@ export default class Send extends Component {
<FeePicker
feeChoices={this.state.feeChoices}
feeSelect={this.feeSelect}
feeDismiss={this.feeDismiss}
/>
}
</Col>