Skip to content

Fix custom system-messages not applied to auto-generated nav buttons#267

Open
Hergie wants to merge 1 commit intosurveydown-dev:mainfrom
Hergie:fix/system-messages-nav-buttons
Open

Fix custom system-messages not applied to auto-generated nav buttons#267
Hergie wants to merge 1 commit intosurveydown-dev:mainfrom
Hergie:fix/system-messages-nav-buttons

Conversation

@Hergie
Copy link
Copy Markdown

@Hergie Hergie commented Mar 3, 2026

I did not manage to set a custom label for automatically generated next buttons (I wanted to translate these into Finnish). Claude's solution below.

Summary

  • Bug 1: extract_html_pages() reads settings_yaml$system_messages (underscore) but the YAML key is system-messages
    (hyphen). This causes custom message overrides (e.g., translating "Next" to another language) to be silently ignored for
    auto-generated navigation buttons. Fixed by using backtick-quoted `system-messages`.

  • Bug 2: survey_files_need_updating() does not check whether _survey/settings.yml is newer than pages.rds. Since
    create_settings_yaml() runs in sd_ui() and may update settings.yml (e.g., when system-messages are added to the YAML header), pages.rds must be regenerated to pick up the new button labels. Without this check, users must manually delete pages.rds to see updated nav button text.

Reproduction

  1. Add a system-messages: block as a top-level YAML key in survey.qmd with e.g. next: "Seuraava"
  2. Run shiny::runApp()
  3. The console shows "Custom system-messages entries found" but the Next button still shows "Next"

Solution

Two changes in R/config.R:

  1. Line 1412: Changed settings_yaml$system_messages to settings_yaml$´system-messages´ so extract_html_pages()
    correctly reads the kebab-case YAML key.
  2. Line 355–362: Added settings.yml timestamp to the staleness check in survey_files_need_updating(), so pages.rds is
    regenerated when settings change.

Verified locally: after applying the fix, custom next labels appear correctly on auto-generated navigation buttons.

Two bugs in R/config.R:

1. extract_html_pages() read settings_yaml$system_messages (underscore)
   but the YAML key is system-messages (hyphen), so custom nav button
   labels were silently ignored. Fixed by using backtick-quoted
   `system-messages`.

2. survey_files_need_updating() did not check whether settings.yml is
   newer than pages.rds, so changes to system-messages required manually
   deleting pages.rds. Added settings.yml to the staleness check.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant