Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ChatInterface button tooltips #7552

Merged
merged 3 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions panel/chat/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,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 @@ -303,12 +306,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()
Loading