Knockout-Contrib / Knockout-Contrib/Knockout-Validation

Redundant dependency in bindingHandlers

Open
#350 0 comments 0 reactions 0 assignees View on GitHub
circle back
Dominant language
JavaScript
Stars
1k
Forks
366
PR merge metrics
No merged PRs in 30d

Description

Both `validationMessage` and `validationElement` bindings depends on modifications of `isModified` observable and re-evaluates each time when isModified is changed. According to this when observable is dirty (i.e. isModified = false) and validation process is triggered (because of change in validatable observable) binding update method will be called 2 times:
1. One because `isValid` is changed
2. Another one because `isModified` is changed (because `isModified` is subscribed to changes of validatable observable)

I see there is a method `showAllMessages` which relies on this behavior and it uses `isModified` observable to hide all the messages what is wrong. Because when somebody calls `showAllMessages` to hide or show errors it modifies `isModified` observable and any other code can't rely on thing that `isModified` shows that observable is modified or not. If we want to hide errors we need to add another observable or just clear errors using `clearError` method

Contributor guide

Open the contributing guide

Research direction

Start in the bindingHandlers implementation for validationMessage and validationElement, then trace their subscriptions to isModified and isValid. Review showAllMessages and clearError to determine the intended way to hide errors without changing modification state. Done means redundant updates are removed and isModified continues to represent whether the observable was modified.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.