Skip to content

Commit

Permalink
Fix chat reaction icons value events + justify-content (#6086)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahuang11 authored and philippjfr committed Dec 20, 2023
1 parent 1f37158 commit 3009daf
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 7 deletions.
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)

0 comments on commit 3009daf

Please sign in to comment.