Fix BetterHtml::DontInterpolateHere in turbo modal partials

Replace raw String interpolation of aria-labelledby attribute with
inline quoted attribute interpolation, which BetterHtml permits.
Always render the attribute since the ID is always generated; a
reference to a non-existent element is harmless when no title is set.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
pull/599/head
Marcelo Paiva 3 weeks ago
parent 7ef0383059
commit 31b745e972

@ -1,6 +1,6 @@
<turbo-frame id="modal"> <turbo-frame id="modal">
<% modal_title_id = "modal_title_#{SecureRandom.hex(4)}" %> <% modal_title_id = "modal_title_#{SecureRandom.hex(4)}" %>
<turbo-modal class="modal modal-open items-start !animate-none overflow-y-auto" data-close-after-submit="<%= local_assigns.key?(:close_after_submit) ? local_assigns[:close_after_submit] : true %>" <%= "aria-labelledby=\"#{modal_title_id}\"" if local_assigns[:title] %>> <turbo-modal class="modal modal-open items-start !animate-none overflow-y-auto" data-close-after-submit="<%= local_assigns.key?(:close_after_submit) ? local_assigns[:close_after_submit] : true %>" aria-labelledby="<%= modal_title_id %>">
<div class="absolute top-0 bottom-0 right-0 left-0" data-action="click:turbo-modal#close"></div> <div class="absolute top-0 bottom-0 right-0 left-0" data-action="click:turbo-modal#close"></div>
<div class="modal-box pt-4 pb-6 px-6 mt-20 max-h-none"> <div class="modal-box pt-4 pb-6 px-6 mt-20 max-h-none">
<% if local_assigns[:title] %> <% if local_assigns[:title] %>

@ -1,6 +1,6 @@
<turbo-frame id="modal"> <turbo-frame id="modal">
<% modal_title_id = "modal_title_#{SecureRandom.hex(4)}" %> <% modal_title_id = "modal_title_#{SecureRandom.hex(4)}" %>
<turbo-modal class="modal modal-open items-start !animate-none overflow-y-auto !justify-normal md:!justify-center" data-close-after-submit="<%= local_assigns.key?(:close_after_submit) ? local_assigns[:close_after_submit] : true %>"<%= html_attributes('aria-labelledby': modal_title_id) if local_assigns[:title] %>> <turbo-modal class="modal modal-open items-start !animate-none overflow-y-auto !justify-normal md:!justify-center" data-close-after-submit="<%= local_assigns.key?(:close_after_submit) ? local_assigns[:close_after_submit] : true %>" aria-labelledby="<%= modal_title_id %>">
<div class="absolute top-0 bottom-0 right-0 left-0" data-action="click:turbo-modal#close"></div> <div class="absolute top-0 bottom-0 right-0 left-0" data-action="click:turbo-modal#close"></div>
<div class="bg-base-100 min-h-screen max-h-screen md:min-h-fit md:mt-3 md:rounded-2xl relative w-full relative overflow-y-auto"> <div class="bg-base-100 min-h-screen max-h-screen md:min-h-fit md:mt-3 md:rounded-2xl relative w-full relative overflow-y-auto">
<% if local_assigns[:title] %> <% if local_assigns[:title] %>

Loading…
Cancel
Save