{
+ const getHierarchicalVariant = () => {
return (
- {variant == 'tree' && getTreeVariant()}
- {variant == 'sentence' && getSentenceVariant()}
+ {variant == HIERARCHICAL_VARIANT && getHierarchicalVariant()}
+ {variant == NON_HIERARCHICAL_VARIANT && getNonHierarchicalVariant()}
>
);
};
diff --git a/packages/ibm-products/src/components/ConditionBuilder/assets/SampleData.js b/packages/ibm-products/src/components/ConditionBuilder/assets/SampleData.js
index a6a8db7a01..b4971c0c22 100644
--- a/packages/ibm-products/src/components/ConditionBuilder/assets/SampleData.js
+++ b/packages/ibm-products/src/components/ConditionBuilder/assets/SampleData.js
@@ -7,7 +7,7 @@
import uuidv4 from '../../../global/js/utils/uuidv4';
-export const sampleDataStructure_tree = {
+export const sampleDataStructure_Hierarchical = {
operator: 'or',
groups: [
{
@@ -128,7 +128,7 @@ export const sampleDataStructure_tree = {
],
};
-export const sampleDataStructure_sentence = {
+export const sampleDataStructure_nonHierarchical = {
groups: [
{
groupOperator: 'and', //'and|or',
diff --git a/packages/ibm-products/src/components/ConditionBuilder/utils/handleKeyboardEvents.js b/packages/ibm-products/src/components/ConditionBuilder/utils/handleKeyboardEvents.js
index b65522584d..b5a94f6535 100644
--- a/packages/ibm-products/src/components/ConditionBuilder/utils/handleKeyboardEvents.js
+++ b/packages/ibm-products/src/components/ConditionBuilder/utils/handleKeyboardEvents.js
@@ -5,7 +5,10 @@
* LICENSE file in the root directory of this source tree.
*/
-import { blockClass } from '../ConditionBuilderContext/DataConfigs';
+import {
+ blockClass,
+ HIERARCHICAL_VARIANT,
+} from '../ConditionBuilderContext/DataConfigs';
import {
checkForHoldingKey,
focusThisField,
@@ -177,7 +180,7 @@ const handleKeyPressForMainContent = (evt, conditionBuilderRef, variant) => {
switch (evt.key) {
case 'ArrowRight':
evt.preventDefault();
- if (variant == 'tree') {
+ if (variant == HIERARCHICAL_VARIANT) {
let allCellsInRow = Array.from(
evt.target
.closest('[role="row"]')
@@ -185,7 +188,7 @@ const handleKeyPressForMainContent = (evt, conditionBuilderRef, variant) => {
);
if (allCellsInRow.length === 1) {
evt.target = evt.target.closest('[role="row"]');
- handleRowNavigationTree(evt, conditionBuilderRef, variant);
+ handleRowNavigationHierarchical(evt, conditionBuilderRef, variant);
//focus next row
} else if (evt.target.getAttribute('role') == 'row') {
//when current focus is on a row, then we need to enter inside and focus the first cell of that row
@@ -210,7 +213,7 @@ const handleKeyPressForMainContent = (evt, conditionBuilderRef, variant) => {
break;
case 'ArrowLeft':
evt.preventDefault();
- if (variant == 'tree') {
+ if (variant == HIERARCHICAL_VARIANT) {
if (evt.target.getAttribute('role') !== 'row') {
//when any cell is focussed, arrow left will select the previous cell or current row
@@ -241,8 +244,8 @@ const handleKeyPressForMainContent = (evt, conditionBuilderRef, variant) => {
case 'ArrowUp':
case 'ArrowDown':
evt.preventDefault();
- if (variant == 'tree') {
- handleRowNavigationTree(evt, conditionBuilderRef, variant);
+ if (variant == HIERARCHICAL_VARIANT) {
+ handleRowNavigationHierarchical(evt, conditionBuilderRef, variant);
} else {
handleRowNavigation(evt, conditionBuilderRef, variant);
}
@@ -282,7 +285,7 @@ const handleRowNavigation = (evt, conditionBuilderRef, variant) => {
conditionBuilderRef
);
};
-const handleRowNavigationTree = (evt, conditionBuilderRef, variant) => {
+const handleRowNavigationHierarchical = (evt, conditionBuilderRef, variant) => {
const rows = getRows(conditionBuilderRef);
const currentRowIndex = getRowIndex(evt.target, conditionBuilderRef);
let nextRowIndex = currentRowIndex;
@@ -341,7 +344,7 @@ const navigateToNextRowCell = (
nextRow?.querySelector(`[data-name="${itemName}"]`),
conditionBuilderRef
);
- } else if (variant === 'tree') {
+ } else if (variant === HIERARCHICAL_VARIANT) {
//when the next row is a if statement , then that row is focused. From any cell of last row of an group , arrow down select the next row (if)
manageTabIndexAndFocus(nextRow, conditionBuilderRef);
}