Skip to content

Commit

Permalink
fixed issue raised when className was added #49
Browse files Browse the repository at this point in the history
  • Loading branch information
saharmehrpour committed Nov 6, 2023
1 parent 2dcaa87 commit e0111ff
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
13 changes: 11 additions & 2 deletions src/ui/RulePad/rulePad.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,8 @@ class RulePad extends Component {
autoCompleteArray: []
};

this.shouldUpdate = true;

// existing rule
if (this.ruleIndex >= 0) {
let indices = props.rules.map(d => d.index);
Expand Down Expand Up @@ -658,8 +660,8 @@ class RulePad extends Component {
});
}}
onUpdate={(newAutoCompleteText) => {
if (this.state.autoCompleteArray.map(d => d.text).join(" ") !== newAutoCompleteText
|| this.state.constraintXPath === "" || this.state.quantifierXPath === "") {
if (this.shouldUpdate) {
this.shouldUpdate = false;
verifyTextBasedOnGrammar(newAutoCompleteText)
.then((data) => {
if (this.state.quantifierXPath !== data.quantifierXPath || this.state.constraintXPath !== data.constraintXPath) {
Expand Down Expand Up @@ -1121,6 +1123,13 @@ class RulePad extends Component {
this._mounted = false
}

componentDidUpdate(prevProps, prevState) {
if (prevState.autoCompleteArray.map(d => d.text).join(" ") !==
this.state.autoCompleteArray.map(d => d.text).join(" ")) {
this.shouldUpdate = true;
}
}


/**
* Match nextProps.sentMessages and nextProps.receivedMessages using messageIDs, update XPaths
Expand Down
3 changes: 2 additions & 1 deletion src/ui/RulePad/rulePadTextualEditor/generateGuiTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ const traverseNormalNode = (treeNode, isConstraint = false) => {
// context nodes
let keywords = grammar_keywords.slice().map(w => pluralize(w).split(" ").map(a => a.charAt(0).toUpperCase() + a.slice(1)).join(""));
// ClassNames is not included Grammar keywords
keywords.push("ClassNames");

if (keywords.indexOf(treeNode.nodeType.replace("Context", "")) !== -1) {
let nodeKey = treeNode.nodeType.replace("Context", "")
.replace("ClassNames", "Names");
Expand Down Expand Up @@ -267,6 +267,7 @@ const traverseExpressionNode = (ExpressionNode, isConstraint) => {
let setIsConstraint = ExpressionNode.isConstraint || isConstraint;
// context nodes
let keywords = grammar_keywords.slice().map(w => pluralize(w).split(" ").map(a => a.charAt(0).toUpperCase() + a.slice(1)).join(""));
keywords.push("ClassNames");

if (ExpressionNode.children) {
ExpressionNode.children.forEach(child => {
Expand Down

0 comments on commit e0111ff

Please sign in to comment.