refactor(data): use ancestor-aware visibility in Binder default isApplied#24478
refactor(data): use ancestor-aware visibility in Binder default isApplied#24478Artur- wants to merge 1 commit into
Conversation
…lied Binder's default isAppliedPredicate skips bindings whose field is a non-visible Component during validation and bean writing. The previous check only considered the field's own visibility flag, so a field whose own flag is true but whose parent layout is hidden was still validated — even though the user could neither see the field nor correct any error reported on it. Switch to ComponentUtil.isEffectivelyVisible and update the javadoc on both the default predicate and the related setApplyBindingsToHiddenFields setter to spell out the new definition. Behaviour change at the edge: fields with ancestor-hidden state are now skipped just like fields with their own flag cleared. Follow-up from PR #24326.
|
tltv
left a comment
There was a problem hiding this comment.
Technically change is correct, for new API it would be fine, but with Binder I would reconsider if changing just generate more trouble than help anyone. Note that visibility check can be already explicitly disabled (added just to help migrations since visibility check was added recently).
Needs some tests too.
Concern: Taking ancestor visibility in account in Binder is a bit dangerous now since devs may create Binder, and have a layout that's hidden by default, and bind fields that are inside the layout, and then bind bean/record => resulting fields in the hidden layout not being applied.
This could break existing apps, e.g. when using Binder to do validation for collapsed (hidden) section in the form.



Binder's default isAppliedPredicate skips bindings whose field is a non-visible Component during validation and bean writing. The previous check only considered the field's own visibility flag, so a field whose own flag is true but whose parent layout is hidden was still validated — even though the user could neither see the field nor correct any error reported on it.
Switch to ComponentUtil.isEffectivelyVisible and update the javadoc on both the default predicate and the related
setApplyBindingsToHiddenFields setter to spell out the new definition. Behaviour change at the edge: fields with ancestor-hidden state are now skipped just like fields with their own flag cleared.