Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DropZone Preview on Rails 6.0.x #263

Merged
merged 1 commit into from
Aug 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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