You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been trying to figure out why validation errors are not shown reactively (they are detected) and I think the error is coming from simple schema's tracker integration with autoform. This is from a debugging session and I've not been able to verify by running a local copy so apologies if it's incorrect.
Assuming mainSchema is the schema on the form but bar is empty, bar should set the class has-error and set the help-block. The problem I believe is that the code in ValidationContext does not trigger the tracker dependency to change. ValidationContext._schemaKeys = ["foo"];
So when markKeyChanged is called with "foo.bar" , hasOwnProperty will return false and not trigger a change.
This is the code:
export default class ValidationContext {
constructor(ss) {
this._simpleSchema = ss;
this._schema = ss.schema();
this._schemaKeys = Object.keys(this._schema);
this._validationErrors = [];
// Set up validation dependencies
this._deps = {};
const { tracker } = ss._constructorOptions;
if (tracker) {
this._depsAny = new tracker.Dependency();
this._schemaKeys.forEach((key) => {
this._deps[key] = new tracker.Dependency();
});
}
}
_markKeyChanged(key) {
const genericKey = MongoObject.makeKeyGeneric(key);
if (this._deps.hasOwnProperty(genericKey)) this._deps[genericKey].changed();
}
I'd create a PR but I'm strugling to actually install a local version of simpl-schema to be able to test my change first.
--------Edit---------
So from some local testing it appears the issue is more to do with adding the tracker dependency for each sub schema key so that later marKeyChanged can find it. I have a fix created and will try get a PR created.
The text was updated successfully, but these errors were encountered:
I've been trying to figure out why validation errors are not shown reactively (they are detected) and I think the error is coming from simple schema's tracker integration with autoform. This is from a debugging session and I've not been able to verify by running a local copy so apologies if it's incorrect.
As a simple example, consider:
Assuming
mainSchema
is the schema on the form butbar
is empty,bar
should set the classhas-error
and set thehelp-block
. The problem I believe is that the code inValidationContext
does not trigger the tracker dependency to change.ValidationContext._schemaKeys = ["foo"];
So when markKeyChanged is called with "foo.bar" , hasOwnProperty will return false and not trigger a change.
This is the code:
I'd create a PR but I'm strugling to actually install a local version of simpl-schema to be able to test my change first.
--------Edit---------
So from some local testing it appears the issue is more to do with adding the tracker dependency for each sub schema key so that later marKeyChanged can find it. I have a fix created and will try get a PR created.
The text was updated successfully, but these errors were encountered: