Skip to content

fix: make tutor chat close X actually close the panel#10

Merged
StewAlexander-com merged 1 commit into
mainfrom
fix-tutor-chat-close-button
May 19, 2026
Merged

fix: make tutor chat close X actually close the panel#10
StewAlexander-com merged 1 commit into
mainfrom
fix-tutor-chat-close-button

Conversation

@StewAlexander-com
Copy link
Copy Markdown
Owner

Summary

  • The X close button in the Local Tutor chat panel did not close the panel when clicked.
  • Root cause: .tutor-chat__panel { display: flex } has the same specificity as the UA stylesheet rule [hidden] { display: none }. Because author stylesheets win cascade ties over UA, the hidden attribute was a no-op and toggling it never actually hid the panel.
  • The fix re-asserts display: none for .tutor-chat__panel[hidden], hardens the close button wiring (type=button, non-interactive SVG, preventDefault + stopPropagation), and bumps the panel z-index plus cache-bust versions so the service worker picks up the fixed assets.

Files changed

  • frontend/tutor-chat.css — add [hidden] override; bump panel z-index 60 → 61.
  • frontend/tutor-chat.jstype=button on FAB/close, pointer-events="none" on the close SVG, preventDefault/stopPropagation on handlers.
  • frontend/index.html — bump tutor-chat.css and tutor-chat.js version query strings.
  • frontend/sw.js — bump CACHE_VERSION so the service worker re-fetches the updated shell.
  • backend/tests/test_frontend_integration.py — two new regression checks (CSS [hidden] rule and close-button wiring).

Test plan

  • node --check on every file in frontend/*.js (matches CI's frontend job).
  • pytest -q in backend/ — all 91 tests pass, including the 2 new regression checks.
  • Manual: open the chat panel, click the X with a mouse — panel closes.
  • Manual: tap the X on touch — panel closes.
  • Manual: keyboard — focus the X via Tab, press Enter/Space — panel closes.
  • Manual: press Escape while focused inside the panel — panel closes (pre-existing behavior preserved).
  • Manual: hard-reload to ensure the service-worker cache version bump kicks in.

Root cause: .tutor-chat__panel sets `display: flex`, which has the same
specificity as the UA stylesheet's `[hidden] { display: none }` rule.
Because author stylesheets win cascade ties over UA, the `hidden`
attribute was a no-op and the panel never actually hid when the X was
clicked.

Changes
- tutor-chat.css: add `.tutor-chat__panel[hidden] { display: none }` so
  the hidden attribute reliably hides the panel; bump panel z-index to
  61 so it is unambiguously above the FAB (both were 60).
- tutor-chat.js: add `type="button"` to FAB and close to keep behavior
  predictable; make the close SVG non-interactive (pointer-events="none",
  focusable="false") so the click target is always the button; call
  preventDefault on both, and stopPropagation on the close click.
- index.html + sw.js: bump cache-busting versions so the SW picks up the
  fixed assets.
- tests: two new static checks asserting the regression cannot return:
  the [hidden] CSS rule must be present, and the close button must be
  wired with toggle(false, ...).
@StewAlexander-com StewAlexander-com merged commit ffd931e into main May 19, 2026
5 checks passed
@StewAlexander-com StewAlexander-com deleted the fix-tutor-chat-close-button branch May 19, 2026 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants