fix(game): repair played-row dropdown styling and refresh (#70)
The played-row "Played N times" dropdown regressed when it was migrated
from Alpine to a custom element (commit 1258c52): the hover highlight,
the row-filling click target and a consistent pointer cursor were lost
because the interactive <a>/<button> shrank to its text while the <li>
rows stopped carrying hover/click behaviour. Clicking the row's padding
hit the handler-less <li> and was silently swallowed.
Make each menu item the interactive element itself (block w-full + own
padding + hover highlight + pointer cursor), mirroring the status
selector's _SELECTOR_OPTION_CLASS, so the control fills the whole row.
Also refresh the Play Events section in place: the play-event-row now
dispatches a "play-added" event after recording a play, and
#playevents-container re-fetches itself on it (mirroring the history
section's status-changed refresh), so the table and count badge update
without a full reload.
Add e2e regression tests covering hover highlight, full-row pointer
cursor, the row-wide +1 click target, and the in-place table refresh.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+34
-7
@@ -375,6 +375,15 @@ _PLAYED_MENU = (
|
||||
"bg-gray-800/20 backdrop-blur-lg rounded-md rounded-tl-none border "
|
||||
"border-gray-200 dark:border-gray-700"
|
||||
)
|
||||
# Each menu item is the interactive element itself: it fills the whole row
|
||||
# (block w-full + own padding), carries the hover highlight and pointer cursor,
|
||||
# so there is no handler-less padding to swallow hover/clicks (issue #70).
|
||||
# Mirrors _SELECTOR_OPTION_CLASS in common/components/domain.py.
|
||||
_PLAYED_MENU_ITEM = (
|
||||
"block w-full text-left px-4 py-2 rounded-sm cursor-pointer no-underline "
|
||||
"hover:bg-gray-700 hover:text-white dark:hover:bg-gray-700 "
|
||||
"dark:hover:text-white border-0"
|
||||
)
|
||||
|
||||
|
||||
def _played_row(game: Game, request: HttpRequest) -> Node:
|
||||
@@ -393,15 +402,20 @@ def _played_row(game: Game, request: HttpRequest) -> Node:
|
||||
]
|
||||
menu = Div(data_menu="", hidden=True, class_=_PLAYED_MENU)[
|
||||
Ul()[
|
||||
Li(class_="px-4 py-2")[
|
||||
A(href=reverse("games:add_playevent_for_game", args=[game.id]))[
|
||||
"Add playthrough..."
|
||||
]
|
||||
Li()[
|
||||
A(
|
||||
href=reverse("games:add_playevent_for_game", args=[game.id]),
|
||||
class_=_PLAYED_MENU_ITEM,
|
||||
)["Add playthrough..."]
|
||||
],
|
||||
Li(class_="px-4 py-2 cursor-pointer")[
|
||||
Li()[
|
||||
Element(
|
||||
"button",
|
||||
[("type", "button"), ("data-add-play", "")],
|
||||
[
|
||||
("type", "button"),
|
||||
("data-add-play", ""),
|
||||
("class", _PLAYED_MENU_ITEM),
|
||||
],
|
||||
children=["Played times +1"],
|
||||
)
|
||||
],
|
||||
@@ -820,13 +834,26 @@ def _playevents_section(game: Game) -> SafeText:
|
||||
playevents = game.playevents.all()
|
||||
data = create_playevent_tabledata(playevents, exclude_columns=["Game"])
|
||||
table = SimpleTable(columns=data["columns"], rows=data["rows"])
|
||||
return _game_section(
|
||||
section = _game_section(
|
||||
"Play Events",
|
||||
playevents.count(),
|
||||
table,
|
||||
"No play events yet.",
|
||||
view_all_url=filter_url(PlayEventFilter.where(game=[game.id])),
|
||||
)
|
||||
# Re-fetch this section (table + count badge) when the played-row "+1"
|
||||
# control records a play, so it updates without a full reload. Mirrors the
|
||||
# history section's status-changed refresh.
|
||||
return Div(
|
||||
[
|
||||
("id", "playevents-container"),
|
||||
("hx-get", ""),
|
||||
("hx-trigger", "play-added from:body"),
|
||||
("hx-select", "#playevents-container"),
|
||||
("hx-swap", "outerHTML"),
|
||||
],
|
||||
[section],
|
||||
)
|
||||
|
||||
|
||||
def _history_section(game: Game) -> SafeText:
|
||||
|
||||
Reference in New Issue
Block a user