Skip to content

Commit

Permalink
Trigger text field #clearErrorMessages on click (#397)
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillplatonov authored Mar 16, 2024
1 parent 4d1cf21 commit 720a460
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/components/polaris/text_field_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def input_options
"Polaris-TextField__Input--suffixed": @suffix.present?
)
if @clear_errors_on_focus
prepend_option(opts[:data], :action, "focus->polaris-text-field#clearErrorMessages")
prepend_option(opts[:data], :action, "click->polaris-text-field#clearErrorMessages")
end
prepend_option(opts[:data], :action, "polaris-text-field#syncValue")
end
Expand Down
4 changes: 2 additions & 2 deletions test/components/polaris/text_field_component_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def test_clear_errors_on_focus
clear_errors_on_focus: true
))

assert_selector "input[name=input_name][data-action~='focus->polaris-text-field#clearErrorMessages']"
assert_selector "input[name=input_name][data-action~='click->polaris-text-field#clearErrorMessages']"

render_inline(Polaris::TextFieldComponent.new(
name: :input_name,
Expand All @@ -298,6 +298,6 @@ def test_clear_errors_on_focus
input_options: {data: {action: "custom#action"}}
))

assert_selector "input[name=input_name][data-action~='focus->polaris-text-field#clearErrorMessages']"
assert_selector "input[name=input_name][data-action~='click->polaris-text-field#clearErrorMessages']"
end
end

0 comments on commit 720a460

Please sign in to comment.