【问题标题】:React-Materialize Modal : any key will close the modal unexpectedlyReact-Materialize Modal :任何键都会意外关闭模态
【发布时间】:2020-07-13 12:03:19
【问题描述】:

说明 我有一个带有文本输入的反应物化模式 在选项中,我已将可驳回设置为 false

实际行为: 当我在里面输入文本或任何内容时,任何键都会关闭模式。

预期行为: 我只想在单击按钮关闭或单击按钮提交时关闭模式 你知道为什么任何键都会关闭模式吗?我认为这是因为我的输入上的 OnChange。

谢谢

版本 反应物化:3.5.10 物化CSS:1.0.0 反应:16.12.0

<Form>
  <Modal actions={[ <div>
    <Button className="blue darken-4" size="sm" onClick={()=> this.closeModal()}>Annuler</Button>{' '}
    <Button className="blue darken-4" size="sm" onClick={()=> this.addProd(producerName, producerShare)} >Enregistrer dans la blockchain</Button>
    </div>

    ]} bottomSheet={false} fixedFooter={false} header="Ajouter un coproducteur" id="Modal-0" open={false} options={{ dismissible: false, endingTop: '10%', inDuration: 250, onCloseEnd: null, onCloseStart: null, onOpenEnd: null, onOpenStart: null, opacity:
    0.5, outDuration: 250, preventScrolling: true, startingTop: '4%' }} trigger={
    <Button className="blue darken-4">Ajouter un coproducteur</Button>} >
    <p>

      Veuillez saisir le nom du coproducteur et le pourcentage de ses parts dans le projet
    </p>
    <br></br>


    <TextInput id="producerName" placeholder="Nom" onChange={adresse=> this.setState({producerName: adresse.target.value})} />{' '}
      <br></br>
      <TextInput id="producerShare" placeholder="Part Producteur" onChange={adresse=> this.setState({producerShare: adresse.target.value})} />
        <br></br>
  </Modal>
</Form>

【问题讨论】:

    标签: reactjs modal-dialog state materialize onchange


    【解决方案1】:

    解决办法是去掉 open={false}

    【讨论】:

      猜你喜欢
      • 2018-03-28
      • 2019-03-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-26
      • 2015-03-26
      相关资源
      最近更新 更多