Skip to content

Fix Custom Fields save serialization by moving settings.js to stable data hooks - #358

Merged
admonstrator merged 4 commits into
mainfrom
copilot/fix-custom-fields-save-issue
Sep 25, 2026
Merged

admonstrator merged 4 commits into
mainfrom
copilot/fix-custom-fields-save-issue

Conversation

Copilot AI commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Custom Fields could be added in the Settings UI but failed to persist on save because settings.js still parsed rows using outdated Tailwind-era selectors. This caused client-side serialization failures and left custom_fields empty.

  • Custom field serialization now uses explicit data hooks

    • updateCustomFieldsJson() now reads:
      • data-field-name
      • data-field-type
    • Parsing logic remains the same, but selector coupling to presentation classes is removed.
  • Server-rendered rows now expose the same contract as JS-created rows

    • Added data-field-name and data-field-type to existing Custom Fields rows in views/settings.ejs.
    • This aligns initial render and dynamically added rows under one stable DOM API.
  • Duplicate-name detection aligned with the same selector contract

    • addCustomField() duplicate checks now query the shared name hook instead of legacy class-based selectors.
  • Regression guard for selector drift

    • Added tests/test-settings-custom-fields-selector-sync.js to assert:
      • settings selectors remain data-hook based
      • Custom Fields view markup keeps required hooks
      • stale class-based lookups are not reintroduced
    • Registered in scripts/run-tests.js as settings-custom-fields-selector-sync.
const CUSTOM_FIELD_NAME_SELECTOR = '[data-field-name]';
const CUSTOM_FIELD_TYPE_SELECTOR = '[data-field-type]';

Copilot AI and others added 3 commits September 25, 2026 13:34
Co-authored-by: admonstrator <69824+admonstrator@users.noreply.github.com>
Co-authored-by: admonstrator <69824+admonstrator@users.noreply.github.com>
Co-authored-by: admonstrator <69824+admonstrator@users.noreply.github.com>
@admonstrator
admonstrator requested a balanced review from Copilot September 25, 2026 13:38
@admonstrator admonstrator added the bug Something isn't working label Sep 25, 2026
Copilot AI changed the title [WIP] Fix custom fields saving issue due to outdated CSS selectors Fix Custom Fields save serialization by moving settings.js to stable data hooks Sep 25, 2026
Copilot AI requested a review from admonstrator September 25, 2026 13: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.

Copilot review overview

🟢 Approval recommended

The selector fix is consistent across generated and rendered rows, with targeted regression coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Fixes Custom Fields persistence by aligning serialization with stable data attributes in the settings UI.

Changes:

  • Adds shared selectors and safer Custom Fields serialization.
  • Adds data hooks to server-rendered fields.
  • Registers focused selector-drift regression coverage.
File Description
public/​js/​settings.js Uses stable data hooks for serialization and duplicate detection.
views/​settings.ejs Adds matching hooks to rendered fields.
tests/​test-settings-custom-fields-selector-sync.js Verifies selector and markup alignment.
scripts/​run-tests.js Registers the regression test.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@admonstrator
admonstrator marked this pull request as ready for review September 25, 2026 13:58
@admonstrator
admonstrator merged commit a0d2031 into main Sep 25, 2026
5 of 6 checks passed
@admonstrator
admonstrator deleted the copilot/fix-custom-fields-save-issue branch September 25, 2026 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Custom Fields cannot be saved due to outdated CSS selectors in settings.js

3 participants