Skip to content

Commit

Permalink
Fix backdrop scrolling and change relative height to fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasJanik committed Dec 7, 2023
1 parent 3869c03 commit 16c68e5
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/components/common/modal_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div role="dialog" aria-modal="true" aria-labelledby="modal-title" class="animated fadeIn fixed inset-0 overflow-y-auto flex items-center justify-center" style="z-index: 10000;">
<div class="max-w-lg max-h-screen w-full relative" style="z-index: 1000">
<div class="flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0">
<div class="relative transform overflow-hidden rounded-lg bg-white px-4 pb-4 pt-5 text-left shadow-xl transition-all sm:my-8 w-full sm:max-w-lg sm:p-6 sm:pb-4 flex flex-col" style="<%= @height ? "height: #{@height}" : ""%>">
<div class="relative transform overflow-hidden rounded-lg bg-white px-4 pb-4 pt-5 text-left shadow-xl transition-all sm:my-8 w-full sm:max-w-lg sm:p-6 sm:pb-4 flex flex-col <%= @classes %>">
<% if header %>
<h3 class="text-base font-semibold leading-6 text-gray-900" id="modal-title"><%= header %></h3>
<% end %>
Expand Down
4 changes: 2 additions & 2 deletions app/components/common/modal_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ class ModalComponent < ViewComponent::Base
renders_one :header
renders_one :modal_content

def initialize(height = nil)
@height = height
def initialize(classes = "")
@classes = classes
end

def remove_content_action
Expand Down
10 changes: 4 additions & 6 deletions app/components/tags_assignment/component.html.erb
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
<%= render Common::ModalComponent.new("550px") do |modal| %>
<%= render Common::ModalComponent.new("h-[550px]") do |modal| %>
<% modal.with_header do %>
Úprava štítkov
<% end %>
<% modal.with_modal_content do %>
<%= form_with url: prepare_message_thread_tags_path(@message_thread),
data: { controller: 'debounce', debounce_target: 'form' }, class: "mt-4 flex flex-col grow justify-between overflow-hidden" do |form| %>
<div class="flex flex-col items-start gap-4 max-height-[85%]">
data: { controller: 'debounce', debounce_target: 'form' }, class: "relative mt-4 flex flex-col grow justify-between" do |form| %>
<div class="flex flex-col items-start gap-4">
<div class="w-full">
<%= tag.turbo_frame id: TagsAssignment::Component::SEARCH_FIELD_FRAME do %>
<%= render TagsAssignment::SearchFieldComponent.new %>
<% end %>
</div>

<div class="w-full mb-4 overflow-x-hidden overflow-y-auto">
<div class="w-full mb-4 overflow-x-hidden overflow-y-auto pr-2.5 max-h-[300px] sm:max-h-[350px]">
<% @tags_changes.init_assignments.each do |tag_id, value| %>
<%= hidden_field_tag "tags_assignments[init][#{tag_id}]", value %>
<% end %>
Expand All @@ -26,7 +25,6 @@
<%= tag.turbo_frame id: TagsAssignment::Component::DIFF_FRAME %>
</div>
</div>

<%= tag.turbo_frame id: TagsAssignment::Component::ACTIONS_FRAME do %>
<%= render Common::ModalActionsComponent.new %>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/components/tags_assignment/diff_component.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<% if @diff.number_of_changes > 0 %>
<div class="text-sm w-full mx-2 mb-4">
<div class="text-sm w-full mx-2 my-4">
<p class="mb-2 italic">Po uložení sa vykonajú nasledovné zmeny:</p>
<% if @diff.to_add.present? %>
<p class="mb-2" data-test="to_be_added">Pridajú sa: <%= format_tags(@diff.to_add) %></p>
Expand Down
5 changes: 5 additions & 0 deletions app/javascript/controllers/turbo_content_controller.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { Controller } from "@hotwired/stimulus";

export default class extends Controller {
connect() {
document.body.style.overflow = "hidden"
}

remove() {
document.body.style.overflow = ""
this.element.parentElement.removeAttribute("src")
this.element.parentElement.removeAttribute("complete")
this.element.remove()
Expand Down

0 comments on commit 16c68e5

Please sign in to comment.