Fix for answering preview widgets
The ambiguity of the greyedOut
value and the ways it is passed, caused some problems. There are cases where it is passed through injection by the RccWidgetComponent
(which receives it via input by the parent component RccQuestionLaneComponent
s template. In other cases like with RccSessionRequestPresentOptionsModalComponent
it is set conventionally via input.
NullInjectorError
Source of the
RadioSelectBaseComponent
has the injected value set to be optional
.
But the derived RccRadioSelectComponent
overrides that and makes it mandatory:
The RccSessionRequestPresentOptionsModalComponent
doesn't receive an injected value by RccWidgetComponent. But since the derived
RccRadioSelectComponentis used instead of the
basecomponent, it throws an error for the missing injected value. The default value which was set by the
basecomponent isn't used because of the resulting
NullInjectorError`.
what to do
-
move all the greyedOut logic out from the base, only leaving the @Input() greyedOut
-
differentiate better between the kinds of greyedOut variables, i.e. @Optional() @Inject('greyedOut') injectedGreyedOut: boolean
-
add clear to understand condition for greyedOut
:if (injectedGreyedOut) this.greyedOut = injectedGreyedOut
that states that if there was an (optional) injectedgreyedOut
value passed to use the injected one, otherwise leave thethis.greyedOut
as is (default = false) or use the value received through @Input() -
check all components where greyedOut is used and assess whether it receives it either both through @Input()
as well as@Inject()
-
add @Optional() this is the case -
if it only receives the value through @Inject() because that component is always created dynamically, remove the unnecessary @Input()