Skip to content

Commit f96ed32

Browse files
committed
update logic for closing button
1 parent 5dde752 commit f96ed32

1 file changed

Lines changed: 6 additions & 14 deletions

File tree

crystal_toolkit/components/messageAIO.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -290,27 +290,19 @@ def layout(self) -> html.Div:
290290
)
291291
"""
292292

293-
@callback(
294-
Output(ids.wrapper(MATCH), "style", allow_duplicate=True),
295-
Input(ids.close_button(MATCH), "n_clicks"),
296-
prevent_initial_call=True,
297-
)
298-
def sync_message(close_clicks):
299-
return {"display": "none"}
300-
301293
@callback(
302294
Output(ids.message(MATCH), "children"),
303295
Output(ids.wrapper(MATCH), "style", allow_duplicate=True),
304296
Output(ids.div(MATCH), "style"),
297+
Output(ids.close_button(MATCH), "n_clicks"),
305298
Input(ids.data(MATCH), "data"),
306-
Input(ids.wrapper(MATCH), "style"),
299+
Input(ids.close_button(MATCH), "n_clicks"),
307300
State(ids.div(MATCH), "style"),
308301
prevent_initial_call=True,
309302
)
310-
def update_messages(input_data, cur_wrapper_style, cur_style):
311-
print(input_data)
312-
if not input_data:
313-
return no_update, {"display": "none"}, cur_style
303+
def update_messages(input_data, close_clicks, cur_style):
304+
if close_clicks or not input_data:
305+
return no_update, {"display": "none"}, cur_style, 0
314306

315307
message = input_data.get("message", None)
316308
msg_type = input_data.get("msg_type", "info")
@@ -319,7 +311,7 @@ def update_messages(input_data, cur_wrapper_style, cur_style):
319311
type_style = _TYPE_COLORS.get(msg_type, _TYPE_COLORS["info"])
320312
cur_style.update(type_style)
321313

322-
return message, {"display": "block"}, cur_style
314+
return message, {"display": "block"}, cur_style, 1
323315

324316
"""
325317
@callback(

0 commit comments

Comments
 (0)