Module: UI::SelectScrollUpButtonBehavior

Included in:
SelectScrollUpButton, SelectScrollUpButtonComponent
Defined in:
app/helpers/ui/select_scroll_up_button_behavior.rb,
app/behaviors/ui/select_scroll_up_button_behavior.rb

Overview

UI::SelectScrollUpButtonBehavior

Shared behavior for Select scroll up button across ERB, ViewComponent, and Phlex implementations. This module provides consistent HTML attribute generation and styling.

Instance Method Summary collapse

Instance Method Details

#select_scroll_up_button_classesObject

Returns combined CSS classes



34
35
36
37
38
39
40
# File 'app/helpers/ui/select_scroll_up_button_behavior.rb', line 34

def select_scroll_up_button_classes
  classes_value = respond_to?(:classes, true) ? classes : @classes
  TailwindMerge::Merger.new.merge([
    select_scroll_up_button_base_classes,
    classes_value
  ].compact.join(" "))
end

#select_scroll_up_button_data_attributesObject

Returns data attributes for Stimulus



22
23
24
25
26
27
28
29
30
31
# File 'app/helpers/ui/select_scroll_up_button_behavior.rb', line 22

def select_scroll_up_button_data_attributes
  attributes_value = respond_to?(:attributes, true) ? attributes : @attributes
  base_data = {
    ui__select_target: "scrollUpButton",
    action: "mouseenter->ui--select#scrollUp mouseleave->ui--select#stopScroll",
    slot: "select-scroll-up-button" # ADDED: data-slot attribute
  }

  (attributes_value&.fetch(:data, {}) || {}).merge(base_data)
end

#select_scroll_up_button_html_attributesObject

Returns HTML attributes for the select scroll up button element



9
10
11
12
13
14
15
16
17
18
19
# File 'app/helpers/ui/select_scroll_up_button_behavior.rb', line 9

def select_scroll_up_button_html_attributes
  attributes_value = respond_to?(:attributes, true) ? attributes : @attributes
  {
    class: select_scroll_up_button_classes,
    "aria-hidden": "true",
    # FIXED: Removed display: none - visibility controlled by JavaScript/aria-hidden
    # ADDED: flex-shrink: 0 as per shadcn implementation
    style: "flex-shrink: 0;",
    data: select_scroll_up_button_data_attributes
  }.merge(attributes_value || {})
end