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

Unsupported ViewComponent slots in SMS and Email tools #3102

Closed
body-clock opened this issue Nov 8, 2023 · 3 comments · Fixed by #3120
Closed

Unsupported ViewComponent slots in SMS and Email tools #3102

body-clock opened this issue Nov 8, 2023 · 3 comments · Fixed by #3120

Comments

@body-clock
Copy link

The gemspec for Blacklight specifies a version of ViewComponent that is '>= 2.66', '< 4'. In my project, with ViewComponent 3.0, the SMS and Email tools were not rendering correctly. Per the ViewComponent changelog, ViewComponent 3.0 contains the following breaking changes:

  • BREAKING: Remove deprecated slots setter methods. Use with_SLOT_NAME instead.
  • BREAKING: Remove deprecated SlotsV1 in favor of current SlotsV2.

The SMS and Email tools are still rendered using the deprecated setter methods. Here's the SMS code for example:

<%= render Blacklight::System::ModalComponent.new do |component| %>
  <% component.title { t('blacklight.sms.form.title') } %>

  <% component.body do %>
    <%= render 'sms_form' %>
  <% end %>
<% end %>

This code can be fixed by updating it to the following:

<%= render Blacklight::System::ModalComponent.new do |component| %>
  <% component.with_title { t('blacklight.sms.form.title') } %>

  <% component.with_body do %>
    <%= render 'sms_form' %>
  <% end %>
<% end %>

The alternative solution is to limit the ViewComponent version to something < 3.0, but it seems like transition to the newer setter methods has been started.

@jrochkind
Copy link
Member

Can you say what version of Blacklight you are using please? What version this is broken with, and what version you were previously using that it worked with?

It sounds like maybe we don't have tests covering those components. :(

@jrochkind
Copy link
Member

jrochkind commented Nov 8, 2023

As a workaround until this is fixed, you can probably get things to work by continuing to use view_component 2.x in your app. If the version of BL you are using supports both 2.x and 3.x, you can use 2.x in your app simply by adding this to your local app Gemfile:

gem "view_component", "~> 2.0"

That will make your app restrict to 2.x, even though BL says it supports either 2.x or 3.x -- since you have apparently discovered that certain features are actually broken with 3.x.

@body-clock
Copy link
Author

I'm using Blacklight 8.0.1. I don't have previous experience with Blacklight, so that's all the info I have. I was able to fix this temporarily by adding the following to my gemfile:

gem 'view_component', '~> 2.66'

Thanks for your quick reply.

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 a pull request may close this issue.

2 participants