-
Notifications
You must be signed in to change notification settings - Fork 0
fix: handle preview mode in matching game #34
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -31,6 +31,7 @@ function GamesXBlockMatchingInit(runtime, element) { | |||||||||||||||||
|
|
||||||||||||||||||
| let timerInterval = null; | ||||||||||||||||||
| let timeSeconds = 0; | ||||||||||||||||||
| const isPreviewMode = new URLSearchParams(window.location.search).get('preview') === '1'; | ||||||||||||||||||
|
|
||||||||||||||||||
| function formatTime(seconds) { | ||||||||||||||||||
| const hours = Math.floor(seconds / 3600); | ||||||||||||||||||
|
|
@@ -60,6 +61,45 @@ function GamesXBlockMatchingInit(runtime, element) { | |||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| function refreshGame() { | ||||||||||||||||||
| if (isPreviewMode) { | ||||||||||||||||||
| currentPageIndex = 0; | ||||||||||||||||||
| matchCount = 0; | ||||||||||||||||||
| firstSelection = null; | ||||||||||||||||||
| timeSeconds = 0; | ||||||||||||||||||
| stopTimer(); | ||||||||||||||||||
| $('.matching-end-screen', element).removeClass('active'); | ||||||||||||||||||
| $('.matching-new-best', element).removeClass('active'); | ||||||||||||||||||
| $('.matching-grid', element).show().addClass('active'); | ||||||||||||||||||
| $('.matching-footer', element).show().addClass('active'); | ||||||||||||||||||
|
Comment on lines
+72
to
+73
|
||||||||||||||||||
| $('.matching-grid', element).show().addClass('active'); | |
| $('.matching-footer', element).show().addClass('active'); | |
| $('.matching-grid', element).removeAttr('style').addClass('active'); | |
| $('.matching-footer', element).removeAttr('style').addClass('active'); |
Copilot
AI
Apr 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preview-mode completion always activates .matching-new-best, which renders the copy “A new personal best!” even though preview mode has no persisted best-time data. Consider showing a neutral results state for preview (e.g., reuse .matching-prev-best with adjusted copy, or add a dedicated preview block) so the end screen doesn’t present incorrect information.
| $('.matching-new-best', element).addClass('active'); | |
| $('.matching-grid', element).hide(); | |
| $('.matching-footer', element).hide(); | |
| $('#matching-current-result', element).text(formatTime(timeSeconds)); | |
| $('.matching-new-best', element).removeClass('active'); | |
| $('.matching-prev-best', element).removeClass('active'); | |
| $('.matching-grid', element).hide(); | |
| $('.matching-footer', element).hide(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing the
:focus-visibleoutline from.matching-boxleaves keyboard users without a visible focus indicator (and the JS explicitly calls.focus()on these elements). Please keep a clear non-color-dependent focus style (e.g., outline/box-shadow) that meets WCAG focus appearance requirements instead ofoutline: none.