Skip to content

Fix: Line breaks rendering in dropdown using html-translate - #6820

Merged
NicolasDorier merged 1 commit into
btcpayserver:masterfrom
bhola-dev58:fix-dropdown-linebreaks-clean
Jul 7, 2025
Merged

NicolasDorier merged 1 commit into
btcpayserver:masterfrom
bhola-dev58:fix-dropdown-linebreaks-clean

Conversation

@bhola-dev58

Copy link
Copy Markdown
Contributor

/cc @NicolasDorier

🛠️ What this PR does

  • Fixes issue [Bug]: Line Breaks <br /> in Dropdown #6783: Line breaks were not rendering correctly in
    Settings → Checkout Appearance → Select a preset.
  • Applied html-translate="true" to translation blocks which makes wrappers instead of showing <br /> in the page.
  • Updated both view templates accordingly to improve security and accessibility.

🧾 Original Files & Lines

BTCPayServer/Views/UIStores/CheckoutAppearance.cshtml

121    <span class="note" text-translate="true">Enhance the checkout process for online purchases.<br />This assumes the payment page will be displayed...</span>

126    <span class="note" text-translate="true">Enhance the checkout process for in-store purchases.<br />This assumes the payment page will be displayed...</span>

🧾 Updated Files & Lines

BTCPayServer/Views/UIStores/CheckoutAppearance.cshtml

121    <span class="note" text-translate="true" html-translate="true">Enhance the checkout process for online purchases.<br />This assumes the payment page will be displayed...</span>

126    <span class="note" text-translate="true" html-translate="true">Enhance the checkout process for in-store purchases.<br />This assumes the payment page will be displayed...</span>

🔎 Note: The root cause appears to be sanitization during rendering. This update restructures the content for better rendering without requiring @Html.Raw().


📸 Visual Preview

Before:

After:


✅ Why this approach?

  • Leverages native BTCPay localization rendering features (html-translate="true").
  • Keeps translations clean while supporting basic HTML rendering like <br />.
  • Minimal, scoped, and non-invasive fix.

🙏 Notes

I'm still learning open-source contribution best practices.
This is a clean and focused PR addressing only the issue mentioned. Thank you again for your guidance — I look forward to your feedback and review!

@coderabbitai

coderabbitai Bot commented Jul 2, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

The change updates two <span> elements within the checkout presets dropdown in the CheckoutAppearance.cshtml view by adding the html-translate="true" attribute. These spans, which display notes for the "Online" and "In-store" options, previously used only text-translate="true". The new attribute allows translation systems to correctly process and translate HTML content within the spans, including handling embedded <br /> tags. No other files or logic were modified.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 0

♻️ Duplicate comments (1)
BTCPayServer/Views/UIStores/CheckoutAppearance.cshtml (1)

123-127: Apply the same clean-up to the “In-store” note.

-<span class="note" text-translate="true" html-translate="true">
+<span class="note" html-translate="true">
🧹 Nitpick comments (1)
BTCPayServer/Views/UIStores/CheckoutAppearance.cshtml (1)

118-122: Remove redundant text-translate – keep only html-translate.

html-translate="true" already registers the string for localisation and signals that embedded HTML is safe to render. Having both attributes can:

• generate two resource keys, or
• cause the helper to revert to the plain-text pathway, defeating the purpose of this fix.

Also trim the double space for consistency.

-<span class="note" text-translate="true"  html-translate="true">
+<span class="note" html-translate="true">
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 756f482 and acf087a.

📒 Files selected for processing (1)
  • BTCPayServer/Views/UIStores/CheckoutAppearance.cshtml (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: NicolasDorier
PR: btcpayserver/btcpayserver#0
File: :0-0
Timestamp: 2025-04-22T06:54:36.253Z
Learning: Do not edit or modify PR descriptions in the btcpayserver repository as requested by NicolasDorier.
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build_and_test

@dstrukt
dstrukt self-requested a review July 3, 2025 23:13

@dstrukt dstrukt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can't comment on code, but visually, looks good!

Thanks for picking this up and working with us on good coding standards!

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