Skip to content

Commit f535687

Browse files
committed
Re-enable canvas on user input with no value
1 parent d9aeca0 commit f535687

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

examples/chem-sync-local-flask/local_app/benchling_app/views/chemical_preview.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
SectionUiBlockType,
1616
)
1717

18+
from local_app.benchling_app.views.canvas_initialize import input_blocks
1819
from local_app.benchling_app.views.constants import (
1920
CANCEL_BUTTON_ID,
2021
CID_KEY,
@@ -43,11 +44,18 @@ def render_preview_canvas(
4344
canvas_builder.to_update(),
4445
)
4546
else:
47+
user_input = canvas_builder.inputs_to_dict()[SEARCH_TEXT_ID]
48+
# Clear the search input and re-enable canvas so user can input a new search
49+
canvas_builder = canvas_builder.with_blocks(input_blocks()).with_enabled()
50+
session.app.benchling.apps.update_canvas(
51+
canvas_id,
52+
canvas_builder.to_update(),
53+
)
4654
session.close_session(
4755
AppSessionUpdateStatus.SUCCEEDED,
4856
messages=[
4957
AppSessionMessageCreate(
50-
f"Couldn't find any chemicals for '{canvas_builder.inputs_to_dict()[SEARCH_TEXT_ID]}'",
58+
f"Couldn't find any chemicals for '{user_input}'",
5159
style=AppSessionMessageStyle.INFO,
5260
),
5361
],

0 commit comments

Comments
 (0)