Multiline ChatInput

solara.lab.ChatInput is great but it doesn't allow multi-line input (shift+enter to line break will just send the message). I've tried solara.InputTextArea with update_events=["keyup.enter"] instead for linebreaks to work, and they do, but now pressing "enter" just linebreaks and doesn't send the message. What should I do short of dropping down to js?
1 Reply
Ahmed Moubtahij
Ahmed MoubtahijOP2w ago
solara.lab.ChatInput(send_callback=register_user_msg)
solara.lab.ChatInput(send_callback=register_user_msg)
text_input = sol.use_reactive("")
sol.InputTextArea(
label="",
value=text_input,
auto_grow=True,
rows=1,
continuous_update=False,
update_events=["keyup.enter"],
on_value=lambda msg: (
register_user_msg(msg),
text_input.set("")
) if msg.strip() else None,
)
text_input = sol.use_reactive("")
sol.InputTextArea(
label="",
value=text_input,
auto_grow=True,
rows=1,
continuous_update=False,
update_events=["keyup.enter"],
on_value=lambda msg: (
register_user_msg(msg),
text_input.set("")
) if msg.strip() else None,
)
Ah, found the solution: I needed update_events=["keyup.enter.exact"]

Did you find this page helpful?