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

reproduce issue with select tag and morph #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.3
3.1.4
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby "3.1.3"
ruby "3.1.4"

# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 7.0.4", ">= 7.0.4.3"
Expand All @@ -19,7 +19,7 @@ gem "puma", "~> 5.0"
gem "importmap-rails"

# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
gem "turbo-rails"
gem "turbo-rails", "= 2.0.0.pre.beta.2"

# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
gem "stimulus-rails"
Expand Down
7 changes: 4 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ GEM
stringio (3.1.0)
thor (1.3.0)
timeout (0.4.1)
turbo-rails (1.5.0)
turbo-rails (2.0.0.pre.beta.2)
actionpack (>= 6.0.0)
activejob (>= 6.0.0)
railties (>= 6.0.0)
Expand All @@ -217,6 +217,7 @@ GEM

PLATFORMS
arm64-darwin-22
arm64-darwin-23

DEPENDENCIES
bootsnap
Expand All @@ -231,13 +232,13 @@ DEPENDENCIES
sprockets-rails
sqlite3 (~> 1.4)
stimulus-rails
turbo-rails
turbo-rails (= 2.0.0.pre.beta.2)
tzinfo-data
web-console
webdrivers

RUBY VERSION
ruby 3.1.3p185
ruby 3.1.4p223

BUNDLED WITH
2.4.3
15 changes: 15 additions & 0 deletions app/controllers/test_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class TestController < ApplicationController
def index
@test = session[:test].presence&.to_i || 1
numbers = [@test]
numbers += 5.times.map { |i| @test + i + 1 }
numbers += 5.times.map { |i| @test - i - 1 }

@available_options = numbers.sort.map { |i| ["Option #{i}", i] }
end

def create
session[:test] = params[:test]
redirect_to action: :index
end
end
4 changes: 4 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
<%= javascript_importmap_tags %>

<%= turbo_refreshes_with method: :morph, scroll: :preserve %>

<%= yield :head %>
</head>

<body>
Expand Down
8 changes: 8 additions & 0 deletions app/views/test/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<p>Selected Option: <%= @test %></p>

<%= form_tag test_path do %>
<%= select_tag :test,
options_for_select(@available_options, @test),
onchange: "this.form.requestSubmit()"
%>
<% end %>
3 changes: 3 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@

# Defines the root path route ("/")
# root "articles#index"
post :test, to: "test#create"

root "test#index"
end