Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
340 views
in Technique[技术] by (71.8m points)

python - Modal popup disappears on keystroke

In my dash application, I have a modal popup defined. I referenced the example in: https://dash-bootstrap-components.opensource.faculty.ai/docs/components/modal/

The modal popup disappears upon a keystroke in any of the text fields. I can't figure out what's going on. Is there a property I can set or modify my code to not have it disappear?

# Add new property modal
            dbc.Modal(
                [
                      dbc.ModalHeader("Add new property and lease information", style={"color":"white"}),
                      dbc.ModalBody(
                          [

                              dbc.InputGroup(
                                  [

                                      dbc.Label("Tenant:  "), 
                                      dcc.Input(id="Tenant"), 


                                      dbc.Label("Industry:  "),
                                      dcc.Input(id="Industry"),


                                      dbc.Label("Address:  "),
                                      dcc.Input(id="Street_Address"),


                                      dbc.Label("City: "),
                                      dcc.Input(id="City"),


                                      dbc.Label("Zip: "),
                                      dbc.Input(id="Zip"),

                                  ],

                                  
                              ),

                              
                              .....
                              .....


                              # property type
                              dbc.InputGroup(
                                  [

                                     dbc.Label("Property type", style={"color":"white", "margin-right":"4px"}),
                                     dbc.RadioItems(
                                                    id="prop-type-2",
                                                    persistence=True,
                                                    persistence_type="memory",
                                                    options=[
                                                      {"label": "Office", "value": "Office"},
                                                      {"label": "Retail", "value": "Retail"},
                                                      {"label": "Industrial", "value": "Industrial"},
                                                      {"label": "Flex", "value": "Flex"},
                                                      ],
                                                      value=1,
                                                      style={"margin-left":"8px"}
                                     ),

                               ],
                             ),

                              dbc.InputGroup(
                                  [

                                      dbc.Label("Lease type: "),
                                      dcc.Dropdown(

                                              id="lease-type-2",
                                              persistence=True,
                                              persistence_type="memory",
                                              options=[

                                                  {"label": "Gross or Full Service", "value": "Gross or Full Service"},
                                                  {"label": "Modified Gross", "value": "Modified Gross"},
                                                  {"label": "Triple Net Lease", "value": "NNN"}
                                                  #{"label": "Flex", "value": "Flex"},
                                                  #{"label": "Sublease", "value": "Sublease"}

                                              ],
                                              placeholder="Select",
                                      ),

                                  ],
                                  
                              ),



                              dbc.InputGroup(
                                  [

                                      dbc.Label("Class: "),
                                      dcc.Dropdown(

                                              id="prop-class",
                                              persistence=True,
                                              persistence_type="memory",
                                              options=[

                                                  {"label": "A", "value": "A"},
                                                  {"label": "B/C", "value": "BC"}

                                              ],
                                              placeholder="Bldg. class",
                                      ),

                                      dbc.Label("Floor: "),
                                      


                            # Close ModalBody
                            ]),

                            dbc.ModalFooter(
                                  [
                                      dbc.Button("SAVE", color="primary", id="save", className="mr-1"),
                                  ]
                            ),
                    # Close Modal
                    ],
                    id="modal-2",
                ),

# Add property and lease information


@app.callback(Output("modal-2", "is_open"),
             [
              Input("Tenant", "value"),
              Input("Industry", "value"),
              Input("Address", "value"),
              Input("add-prop-btn", "n_clicks"),
              Input("save", "n_clicks")
             ],
             [State("modal-2", "is_open")],
             )
def add_prop(tenant, industry, address, btn_click, save, is_open):

    if btn_click:

        return not open

    elif save:

        return open
question from:https://stackoverflow.com/questions/65950364/modal-popup-disappears-on-keystroke

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...