Skip to content

fix: handle preview mode in matching game - #34

Merged
pganesh-apphelix merged 1 commit into
mainfrom
fix/TNL2-550
May 5, 2026
Merged

pganesh-apphelix merged 1 commit into
mainfrom
fix/TNL2-550

Conversation

@pganesh-apphelix

Copy link
Copy Markdown
Contributor

Description

This PR adds support for a preview mode in the matching game, allowing the game to run without backend calls by initializing and completing the game entirely on the client side when preview=1 is present in the URL.
It also removes the focus-visible outline styling from matching boxes.

Jira

Version

  • 1.0.17

Copilot AI review requested due to automatic review settings April 27, 2026 12:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a client-side “preview mode” to the matching game (triggered by ?preview=1) so the game can be refreshed and completed without backend handler calls, and updates matching box focus styling.

Changes:

  • Add preview=1 URL flag handling to refresh and complete the matching game fully client-side.
  • Update matching end-screen behavior in preview mode (client-side completion flow).
  • Remove :focus-visible outline styling from matching boxes; bump package version to 1.0.17.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
setup.py Bumps package version to 1.0.17.
games/static/js/src/matching.js Adds preview-mode branching for refresh and completion to avoid backend calls.
games/static/css/matching.css Changes focus-visible styling on matching boxes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

outline: 2px solid var(--primary-500, #00262B);
outline-offset: 2px;
box-shadow: 0 0 0 4px rgba(0, 38, 43, 0.2);
outline: none;

Copilot AI Apr 27, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the :focus-visible outline from .matching-box leaves 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 of outline: none.

Suggested change
outline: none;
outline: 3px solid var(--primary-500, #00262B);
outline-offset: 2px;

Copilot uses AI. Check for mistakes.
Comment on lines +72 to +73
$('.matching-grid', element).show().addClass('active');
$('.matching-footer', element).show().addClass('active');

Copilot AI Apr 27, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In preview mode, using jQuery .show() on .matching-grid / .matching-footer will set an inline display: block, which overrides the CSS that expects .matching-grid.active { display: grid } and .matching-footer.active { display: flex }. This can break layout after completing once (because hide() sets inline styles too). Prefer toggling the active class (and removing any inline style from prior hide()), instead of show()/hide() here.

Suggested change
$('.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 uses AI. Check for mistakes.
Comment on lines +325 to +328
$('.matching-new-best', element).addClass('active');
$('.matching-grid', element).hide();
$('.matching-footer', element).hide();
$('#matching-current-result', element).text(formatTime(timeSeconds));

Copilot AI Apr 27, 2026

Copy link

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.

Suggested change
$('.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();

Copilot uses AI. Check for mistakes.
@pganesh-apphelix
pganesh-apphelix merged commit a5236ff into main May 5, 2026
6 of 8 checks passed
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.

3 participants