From d2e6aa24d44fdb194fa386aead2ce9b1661211d1 Mon Sep 17 00:00:00 2001 From: Gareth Jones <3151613+G-Rath@users.noreply.github.com> Date: Tue, 30 Jun 2026 09:10:01 +1200 Subject: [PATCH 1/4] fix: make alert message focusable for accessibility --- lib/bootstrap_form/helpers/bootstrap.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bootstrap_form/helpers/bootstrap.rb b/lib/bootstrap_form/helpers/bootstrap.rb index 1cf39ce4..f83893c8 100644 --- a/lib/bootstrap_form/helpers/bootstrap.rb +++ b/lib/bootstrap_form/helpers/bootstrap.rb @@ -9,7 +9,7 @@ def alert_message(title, options={}) css = options[:class] || "alert alert-danger" return unless object.respond_to?(:errors) && object.errors.full_messages.any? - tag.div class: css do + tag.div class: css, tabindex: "-1" do if options[:error_summary] == false title else From 40cf5dfb541f816fd921c74729724d85abd293f1 Mon Sep 17 00:00:00 2001 From: Gareth Jones <3151613+G-Rath@users.noreply.github.com> Date: Tue, 29 Sep 2026 15:21:49 +1300 Subject: [PATCH 2/4] feat: pass extra `alert_message` keywords to `div` --- lib/bootstrap_form/helpers/bootstrap.rb | 2 +- test/bootstrap_form_test.rb | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/bootstrap_form/helpers/bootstrap.rb b/lib/bootstrap_form/helpers/bootstrap.rb index f83893c8..7f3d7d3f 100644 --- a/lib/bootstrap_form/helpers/bootstrap.rb +++ b/lib/bootstrap_form/helpers/bootstrap.rb @@ -9,7 +9,7 @@ def alert_message(title, options={}) css = options[:class] || "alert alert-danger" return unless object.respond_to?(:errors) && object.errors.full_messages.any? - tag.div class: css, tabindex: "-1" do + tag.div class: css, **options.except(:class, :error_summary) do if options[:error_summary] == false title else diff --git a/test/bootstrap_form_test.rb b/test/bootstrap_form_test.rb index 33d04f23..979d9bd1 100644 --- a/test/bootstrap_form_test.rb +++ b/test/bootstrap_form_test.rb @@ -593,6 +593,23 @@ def warn(message, ...) assert_equivalent_html expected, @builder.alert_message("Please fix the following errors:", class: "my-css-class") end + test "alert_message passes extra options through as HTML attributes" do + @user.email = nil + assert @user.invalid? + + expected = <<~HTML +
Please fix the following errors:
+