Fix components not updating when the enable condition changed
This commit is contained in:
parent
a0cb05b294
commit
42e312c701
1 changed files with 11 additions and 6 deletions
|
|
@ -50,16 +50,20 @@ export default class UiItem<I:Object>
|
||||||
* any function type or if it is a TopicDependentOption or a
|
* any function type or if it is a TopicDependentOption or a
|
||||||
* StateDependentOption. This should be fixed.
|
* StateDependentOption. This should be fixed.
|
||||||
*/
|
*/
|
||||||
isEnabled() {
|
rawIsEnabled(props: UiItemProps<I>) {
|
||||||
if (Object.keys(this.props.item).includes("enableCondition") &&
|
if (Object.keys(props.item).includes("enableCondition") &&
|
||||||
typeof this.props.item.enableCondition == "function") {
|
typeof props.item.enableCondition == "function") {
|
||||||
const enableCondition = this.props.item.enableCondition;
|
const enableCondition = props.item.enableCondition;
|
||||||
const state = this.props.state;
|
const state = props.state;
|
||||||
return enableCondition(state);
|
return enableCondition(state);
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isEnabled() {
|
||||||
|
return this.rawIsEnabled(this.props);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class UiControl<I: UIControl> extends UiItem<I> {
|
export class UiControl<I: UIControl> extends UiItem<I> {
|
||||||
|
|
@ -86,7 +90,8 @@ export class UiControl<I: UIControl> extends UiItem<I> {
|
||||||
shouldComponentUpdate(nextProps: UiItemProps<I>) { // TODO: Fix Flow
|
shouldComponentUpdate(nextProps: UiItemProps<I>) { // TODO: Fix Flow
|
||||||
return nextProps.item.topic !== this.props.item.topic
|
return nextProps.item.topic !== this.props.item.topic
|
||||||
|| nextProps.state[nextProps.item.topic] !==
|
|| nextProps.state[nextProps.item.topic] !==
|
||||||
this.props.state[this.props.item.topic];
|
this.props.state[this.props.item.topic]
|
||||||
|
|| this.isEnabled() !== this.rawIsEnabled(nextProps);
|
||||||
}
|
}
|
||||||
|
|
||||||
getValue() {
|
getValue() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue