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

Fix chat reaction icons value events + justify-content #6086

Merged
merged 3 commits into from
Dec 19, 2023
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
14 changes: 8 additions & 6 deletions panel/chat/icon.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,14 @@ def _update_active_icons(self):
icon.active_icon = self.active_icons.get(option, "")

def _update_value(self, event):
icon = event.obj.name
value = event.new
if value and icon not in self.value:
self.value.append(icon)
elif not value and icon in self.value:
self.value.remove(icon)
reaction = event.obj.name
icon_value = event.new
reactions = self.value.copy()
if icon_value and reaction not in self.value:
reactions.append(reaction)
elif not icon_value and reaction in self.value:
reactions.remove(reaction)
self.value = reactions


class ChatCopyIcon(ReactiveHTML):
Expand Down
1 change: 0 additions & 1 deletion panel/dist/css/chat_message.css
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@
display: flex;
flex-direction: column;
align-items: start;
justify-content: end;
width: fit-content;
margin-block: 0px;
margin-inline: 2px;
Expand Down
27 changes: 27 additions & 0 deletions panel/tests/ui/chat/test_chat_reaction_icon.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import pytest

pytest.importorskip("playwright")


from panel.chat import ChatReactionIcons
from panel.tests.util import serve_component, wait_until

pytestmark = pytest.mark.ui


def test_toggle_icon_click(page):
icons = ChatReactionIcons(options={"like": "thumb-up", "dislike": "thumb-down"}, value=["dislike"])
serve_component(page, icons)

assert icons.value == ["dislike"]
page.locator(".ti-thumb-up").click()
wait_until(lambda: icons.value == ["dislike", "like"], page)

page.locator(".ti-thumb-down-filled").click()
wait_until(lambda: icons.value == ["like"], page)

page.locator(".ti-thumb-up-filled").click()
wait_until(lambda: icons.value == [], page)

page.locator(".ti-thumb-up").click()
wait_until(lambda: icons.value == ["like"], page)