Skip to content

Commit

Permalink
Add ChatInterface button tooltips (#7552)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahuang11 authored Dec 17, 2024
1 parent dba5062 commit ad862e5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
11 changes: 8 additions & 3 deletions panel/chat/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ class ChatInterface(ChatFeed):
show_button_name = param.Boolean(default=None, doc="""
Whether to show the button name.""")

show_button_tooltips = param.Boolean(default=False, doc="""
Whether to show the button tooltips.""")

user = param.String(default="User", doc="""
Name of the ChatInterface user.""")

Expand Down Expand Up @@ -306,12 +309,14 @@ def _init_widgets(self):
visible = self.param[f'show_{action}'] if action != "stop" else False
except KeyError:
visible = True
show_expr = self.param.show_button_name.rx()
show_name_expr = self.param.show_button_name.rx()
show_tooltip_expr = self.param.show_button_tooltips.rx()
button = Button(
name=show_expr.rx.where(button_data.name.title(), ""),
name=show_name_expr.rx.where(button_data.name.title(), ""),
description=show_tooltip_expr.rx.where(f"Click to {button_data.name.lower()}", None),
icon=button_data.icon,
sizing_mode="stretch_width",
max_width=show_expr.rx.where(90, 45),
max_width=show_name_expr.rx.where(90, 45),
max_height=50,
margin=(0, 5, 0, 0),
align="center",
Expand Down
11 changes: 11 additions & 0 deletions panel/tests/ui/chat/test_chat_interface_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,14 @@ def test_chat_interface_custom_js_string(page):
msg = msg_info.value

assert msg.args[0].json_value() == "Clicked"



def test_chat_interface_show_button_tooltips(page):
chat_interface = ChatInterface(show_button_tooltips=True)
serve_component(page, chat_interface)

help_button = page.locator("button", has_text="send")
help_button.hover()

expect(page.locator(".bk-Tooltip")).to_be_visible()

0 comments on commit ad862e5

Please sign in to comment.