fix(input): don't show success feedback when value was not set
This commit is contained in:
parent
8dc47c1b93
commit
21dc77e587
5 changed files with 16 additions and 8 deletions
|
@ -6,6 +6,8 @@ class Dsfr::InputComponent < ApplicationComponent
|
|||
delegate :object, to: :@form
|
||||
delegate :errors, to: :object
|
||||
|
||||
attr_reader :attribute
|
||||
|
||||
# use it to indicate detailed about the inputs, ex: https://www.systeme-de-design.gouv.fr/elements-d-interface/modeles-et-blocs-fonctionnels/demande-de-mot-de-passe
|
||||
# it uses aria-describedby on input and link it to yielded content
|
||||
renders_one :describedby
|
||||
|
|
|
@ -23,7 +23,7 @@ module Dsfr
|
|||
|
||||
{
|
||||
"#{dsfr_group_classname}--error" => errors_on_attribute?,
|
||||
"#{dsfr_group_classname}--valid" => !errors_on_attribute? && errors_on_another_attribute?
|
||||
"#{dsfr_group_classname}--valid" => !errors_on_attribute? && errors_on_another_attribute? && object.public_send(attribute).present?
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -51,9 +51,9 @@ module Dsfr
|
|||
def attribute_or_rich_body
|
||||
case @input_type
|
||||
when :rich_text_area
|
||||
@attribute.to_s.sub(/\Arich_/, '').to_sym
|
||||
attribute.to_s.sub(/\Arich_/, '').to_sym
|
||||
else
|
||||
@attribute
|
||||
attribute
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
class EditableChamp::ChampLabelComponent < ApplicationComponent
|
||||
include Dsfr::InputErrorable
|
||||
|
||||
attr_reader :attribute
|
||||
|
||||
def initialize(form:, champ:, seen_at: nil)
|
||||
@form, @champ, @seen_at = form, champ, seen_at
|
||||
@attribute = :value
|
||||
|
|
|
@ -4,6 +4,8 @@ class EditableChamp::ChampLabelContentComponent < ApplicationComponent
|
|||
include ApplicationHelper
|
||||
include Dsfr::InputErrorable
|
||||
|
||||
attr_reader :attribute
|
||||
|
||||
def initialize(form:, champ:, seen_at: nil)
|
||||
@form, @champ, @seen_at = form, champ, seen_at
|
||||
@attribute = :value
|
||||
|
|
|
@ -3,6 +3,13 @@
|
|||
class EditableChamp::EditableChampBaseComponent < ApplicationComponent
|
||||
include Dsfr::InputErrorable
|
||||
|
||||
attr_reader :attribute
|
||||
|
||||
def initialize(form:, champ:, seen_at: nil, opts: {})
|
||||
@form, @champ, @seen_at, @opts = form, champ, seen_at, opts
|
||||
@attribute = :value
|
||||
end
|
||||
|
||||
def dsfr_champ_container
|
||||
:div
|
||||
end
|
||||
|
@ -14,9 +21,4 @@ class EditableChamp::EditableChampBaseComponent < ApplicationComponent
|
|||
def describedby_id
|
||||
@champ.describedby_id
|
||||
end
|
||||
|
||||
def initialize(form:, champ:, seen_at: nil, opts: {})
|
||||
@form, @champ, @seen_at, @opts = form, champ, seen_at, opts
|
||||
@attribute = :value
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue