Fix: selector & rerender

This commit is contained in:
Dreamacro 2018-12-08 22:29:08 +08:00
parent ac6bac65aa
commit 3bf124dbb3
2 changed files with 11 additions and 16 deletions

View File

@ -40,10 +40,6 @@ export class Select extends React.Component<SelectProps, SelectState> {
hasCreateDropList: false hasCreateDropList: false
} }
constructor (props) {
super(props)
}
componentDidMount () { componentDidMount () {
document.addEventListener('click', this.handleGlobalClick, true) document.addEventListener('click', this.handleGlobalClick, true)
this.setState({ dropdownListStyles: this.calculateAttachmentPosition() }) this.setState({ dropdownListStyles: this.calculateAttachmentPosition() })
@ -91,8 +87,7 @@ export class Select extends React.Component<SelectProps, SelectState> {
return { return {
top: Math.floor(targetRectInfo.top) - 10, top: Math.floor(targetRectInfo.top) - 10,
left: Math.floor(targetRectInfo.left) - 10, left: Math.floor(targetRectInfo.left) - 10
width: Math.floor(targetRectInfo.width) + 10
} }
} }

View File

@ -47,10 +47,10 @@ class Proxies extends React.Component<ProxiesProps, ProxiesState> {
<Icon type="plus" size={20} style={{ fontWeight: 'bold' }} /> <Icon type="plus" size={20} style={{ fontWeight: 'bold' }} />
</Header> </Header>
{ {
config.state === 'ok' && <ul className="proxies-list"> config.config.proxy.length !== 0 && <ul className="proxies-list">
{ {
config.config.proxy.map((p, index) => ( config.config.proxy.map((p, index) => (
<li key={index}> <li key={p.name}>
<Proxy config={p} onEdit={() => this.setState({ <Proxy config={p} onEdit={() => this.setState({
showModifyProxyDialog: true, showModifyProxyDialog: true,
activeConfig: p, activeConfig: p,
@ -65,15 +65,15 @@ class Proxies extends React.Component<ProxiesProps, ProxiesState> {
<div className="proxies-container"> <div className="proxies-container">
<Header title={t('groupTitle')} /> <Header title={t('groupTitle')} />
</div> </div>
{
showModifyProxyDialog && <ModifyProxyDialog
config={activeConfig}
onOk={this.handleConfigApply}
onCancel={() => this.setState({ showModifyProxyDialog: false, activeConfig: null, activeConfigIndex: -1 })}
/>
}
</div> </div>
{
showModifyProxyDialog && <ModifyProxyDialog
config={activeConfig}
onOk={this.handleConfigApply}
onCancel={() => this.setState({ showModifyProxyDialog: false, activeConfig: null, activeConfigIndex: -1 })}
/>
}
</> </>
) )
} }