Skip to content

Commit

Permalink
Fix DropZone Preview on Rails 6.0.x (#263)
Browse files Browse the repository at this point in the history
This adds Rails 6.0 compatibility for a change in CSS class calculation in ActionView::Helpers::TagHelper
  • Loading branch information
ohrite authored Aug 28, 2022
1 parent 0039dae commit d0200d8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/components/polaris/dropzone_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@
<template data-polaris-dropzone-target="previewTemplate">
<%= tag.div(
data: { polaris_dropzone_target: "preview" },
class: [
"Polaris-DropZone__Preview",
class: {
"Polaris-DropZone__Preview": true,
"Polaris-DropZone__Preview--singleFile": !@multiple,
"Polaris-DropZone__Preview--sizeMedium": @size == :medium,
"Polaris-DropZone__Preview--sizeSmall": @size == :small,
]
}
) do %>
<% if @size.in?(%i[small]) %>
<span class="target"></span>
Expand Down
8 changes: 8 additions & 0 deletions test/components/polaris/dropzone_component_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ def test_default_dropzone
end
end

def test_dropzone_preview_template
rendered = render_inline(Polaris::DropzoneComponent.new(name: :file_input))
template = rendered.at_css("template[data-polaris-dropzone-target=previewTemplate] > *").to_html
template_page = Capybara::Node::Simple.new(template)

assert_selector template_page, ".Polaris-DropZone__Preview", visible: :all
end

def test_dropzone_with_label
render_inline(Polaris::DropzoneComponent.new(label: "Dropzone Label", label_hidden: false))

Expand Down

0 comments on commit d0200d8

Please sign in to comment.