Skip to content

Fix: Country label ignores "Use label" toggle#596

Closed
Copilot wants to merge 3 commits intomainfrom
copilot/fix-country-label-visibility
Closed

Fix: Country label ignores "Use label" toggle#596
Copilot wants to merge 3 commits intomainfrom
copilot/fix-country-label-visibility

Conversation

Copy link
Contributor

Copilot AI commented Mar 10, 2026

The country field label rendered on the frontend regardless of the "Use label" toggle state in the editor.

Root cause

country.php unconditionally included 'fieldHideLabel' => $countryHideLabel (always false unless "Use label as placeholder" was on) in the $fieldOutput array. This hardcoded false clobbered the countryFieldHideLabel = true attribute set by the editor toggle when Helpers::props('field', $attributes, $fieldOutput) merged them.

Fix

  • country.php: Remove fieldHideLabel from the static $fieldOutput array. The existing conditional block already handles setting it to true for the "Use label as placeholder" case — consistent with how select.php handles the same pattern.
// Before — fieldHideLabel: false always overrides the editor attribute
$fieldOutput = [
    ...
    'fieldHideLabel' => $countryHideLabel,  // ← removed
    ...
];

// After — editor's countryFieldHideLabel flows through; only overridden to true when needed
if ($countryHideLabel) {
    $fieldOutput['fieldHideLabel'] = true;
}

Tests

Added Playwright E2E tests in tests/e2e/field-country.test.js covering:

  • country-default: label is visible with correct text when "Use label" is enabled
  • country-hide-label: label is hidden when the "Use label" toggle is turned off (directly validates the bug fix)
  • country-placeholder-use-label: label is hidden when "Use label as placeholder" is enabled (regression check)

Test data was added to tests/e2e/playground/dataset.xml (country form post + page), and tests/e2e/playground/playground.json was updated to load the dataset from the auto-mounted plugin VFS path instead of a hardcoded remote branch URL.

Original prompt

This section details on the original issue you should resolve

<issue_title>[BUG] - Country label shown even if hidden</issue_title>
<issue_description>Noticed that the country label was being shown on the site even if it's turned off:

Image

Image</issue_description>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: goranalkovic-infinum <77000136+goranalkovic-infinum@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix bug where country label is shown when hidden Fix: Country label ignores "Use label" toggle Mar 10, 2026
@goranalkovic-infinum goranalkovic-infinum requested review from a team and iruzevic March 10, 2026 08:43
@iruzevic iruzevic marked this pull request as ready for review March 10, 2026 08:48
@goranalkovic-infinum goranalkovic-infinum requested a review from a team March 10, 2026 08:52
iruzevic
iruzevic previously approved these changes Mar 10, 2026
dadadavorin
dadadavorin previously approved these changes Mar 10, 2026
@goranalkovic-infinum
Copy link
Contributor

@copilot Looks good, but can you please write tests for this?

Co-authored-by: goranalkovic-infinum <77000136+goranalkovic-infinum@users.noreply.github.com>
Copilot AI dismissed stale reviews from dadadavorin and iruzevic via 01b5b0f March 10, 2026 13:02
Copy link
Contributor Author

Copilot AI commented Mar 10, 2026

@copilot Looks good, but can you please write tests for this?

Added in commit 01b5b0f:

  • tests/e2e/field-country.test.js — 3 Playwright E2E tests:

    • country-default: confirms the label renders visibly with correct text
    • country-hide-label: confirms the label is hidden when the "Use label" toggle is off (the bug fix)
    • country-placeholder-use-label: confirms the label is hidden when "Use label as placeholder" is on
  • tests/e2e/playground/dataset.xml — Added the country test form (post 30) and a page (post 35) to host it, with one block per test case.

  • tests/e2e/playground/playground.json — Switched importWxr from a hardcoded remote GitHub URL (feature/tests branch) to a vfs resource pointing to the auto-mounted plugin path, so the local dataset.xml is always used.

@iruzevic iruzevic closed this Mar 11, 2026
@iruzevic iruzevic deleted the copilot/fix-country-label-visibility branch March 11, 2026 15:32
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.

[BUG] - Country label shown even if hidden

4 participants