Skip to content

fix: sync user query with collection link - #6

Merged
Bornholm merged 1 commit into
Bornholm:mainfrom
kvitrvn:fix/keep-user-prompt
Apr 1, 2026
Merged

Bornholm merged 1 commit into
Bornholm:mainfrom
kvitrvn:fix/keep-user-prompt

Conversation

@kvitrvn

@kvitrvn kvitrvn commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

Ref #3
Close #3

This pull request updates the Ask page to improve how the query state is managed and synchronized between the UI and backend. The changes ensure that the results area is only shown after a query is submitted, and they add support for synchronizing the query field across navigation and reloads. The update also injects a JavaScript file for query synchronization and marks up relevant HTML elements for this purpose.

Query state management and UI synchronization:

  • Added a Submitted field to the AskPageVModel struct and updated the logic so the results area is only displayed after a query is submitted, not just when the query string is non-empty. (ask_page.templ, ask_page_templ.go, ask_page.go) [1] [2] [3] [4] [5]
  • Updated the backend to set Submitted when a query is posted and to synchronize the query field from the URL on GET requests. (ask_page.go) [1] [2]

Frontend enhancements for query synchronization:

  • Injected a <script> tag to load /assets/js/query-sync.js with a nonce for CSP compliance, and added data-sync-query and data-sync-query-link attributes to relevant elements for JavaScript handling. (ask_page.templ, ask_page_templ.go) [1] [2] [3] [4] [5] [6]

Other minor updates:

  • Updated generated line numbers in error handling to reflect template changes. (ask_page_templ.go) [1] [2] [3] [4] [5]
  • Updated variable names and indices in generated code to match new logic. (ask_page_templ.go) [1] [2]

These changes together make the Ask page more robust and user-friendly by ensuring consistent query state and a more predictable UI.

@Bornholm
Bornholm self-requested a review April 1, 2026 20:09
@Bornholm
Bornholm merged commit cde2117 into Bornholm:main Apr 1, 2026
1 check 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.

Ne pas vider la question sur une selection de collection

2 participants