Skip to content

fix cell divider#4474

Merged
James-Baloyi merged 13 commits intoshesha-io:mainfrom
James-Baloyi:james/b/table-styles
Feb 2, 2026
Merged

fix cell divider#4474
James-Baloyi merged 13 commits intoshesha-io:mainfrom
James-Baloyi:james/b/table-styles

Conversation

@James-Baloyi
Copy link
Copy Markdown
Contributor

@James-Baloyi James-Baloyi commented Jan 30, 2026

Summary by CodeRabbit

  • New Features

    • Customize action-column icons (size & color) from the Appearance panel; existing tables default to 14px.
  • Style

    • Improved table layout: flex-based rows, consistent cell heights, full-height vertical separators, and unified action-icon styling across cells and controls.
    • Better header alignment mapping for more accurate justify/align behavior.
  • Behavior

    • Row hover, selection and double-click handlers receive richer selected-row context.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jan 30, 2026

Warning

Rate limit exceeded

@James-Baloyi has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 29 minutes and 8 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Walkthrough

Threads two new props, actionIconSize and actionIconColor, from designer defaults through TableWrapper → DataTable → ReactTable into styling hooks; augments row interaction contexts with a selectedRow object; adjusts header/body alignment, vertical separators, background composition, and row/cell layout.

Changes

Cohort / File(s) Summary
DataTable
shesha-reactjs/src/components/dataTable/index.tsx
Added actionIconSize / actionIconColor to IIndexTableProps and component props; forwarded them into tableProps; enriched row action evaluation context with selectedRow (index, row, id).
ReactTable & interfaces
shesha-reactjs/src/components/reactTable/index.tsx, shesha-reactjs/src/components/reactTable/interfaces.ts
Accepted/forwarded actionIconSize / actionIconColor; passed values into styling hooks; updated on-row-hover dispatch to include currentSelectedRow/selectedRow; refined header text-align → justify mapping. Note: interface file contains duplicated declarations.
Styles
shesha-reactjs/src/components/reactTable/styles/styles.ts
Added actionIconSize/actionIconColor to useMainStyles; applied sizing/color across action/CRUD/icon rules; switched body rows to flex layout; added vertical cell separators; adjusted row/cell height and alignment logic.
Designer model & defaults
shesha-reactjs/src/designer-components/dataTable/table/models.ts, shesha-reactjs/src/designer-components/dataTable/table/utils.ts
Added actionIconSize/actionIconColor to table model and defaults (actionIconSize default '14px').
Designer settings
shesha-reactjs/src/designer-components/dataTable/table/tableSettings.ts
Added "Action Column Icons" panel with actionIconSize (text) and actionIconColor (color) settings (jsSetting enabled).
Table component / wrapper / migration
shesha-reactjs/src/designer-components/dataTable/table/tableComponent.tsx, shesha-reactjs/src/designer-components/dataTable/table/tableWrapper.tsx
Added migration step to set default actionIconSize for existing tables; tableWrapper composes background strings more robustly, refactors border/background handling, derives effective body font props from allStyles, and forwards action icon props to DataTable.

Sequence Diagram(s)

sequenceDiagram
    participant Designer as Designer (UI/Defaults)
    participant TableWrapper as TableWrapper
    participant DataTable as DataTable
    participant ReactTable as ReactTable
    participant Styles as StylingHooks

    Designer->>TableWrapper: provide settings (actionIconSize, actionIconColor)
    TableWrapper->>DataTable: render with actionIconSize/actionIconColor
    DataTable->>ReactTable: pass tableProps including actionIconSize/actionIconColor
    ReactTable->>Styles: call useMainStyles/useStyles(actionIconSize, actionIconColor)
    ReactTable->>ReactTable: render rows/cells with styled icons and separators

    Note over ReactTable: Row interaction flow
    ReactTable->>ReactTable: onRowHover/onRowDoubleClick -> build selectedRow {index,row,id}
    ReactTable->>DataTable: dispatchRowEvent(payload + selectedRow)
    DataTable->>Designer: evaluate actions with new context
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • AlexStepantsov

Poem

🐇 I hop through props and stitch a seam,
I set each icon’s size and color to gleam.
Rows whisper which one they are, clear and bright,
Dividers stand tidy, borders set right.
A tiny rabbit cheers this UI delight.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title check ⚠️ Warning The title 'fix cell divider' is misleading; the PR primarily adds actionIconSize and actionIconColor styling props across multiple components, with cell dividers being only one aspect of the styling changes. Revise the title to reflect the main change, such as 'Add action icon styling configuration (size and color)' or 'Add actionIconSize and actionIconColor props to data table components'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
shesha-reactjs/src/designer-components/dataTable/table/tableWrapper.tsx (1)

231-305: ⚠️ Potential issue | 🟠 Major

borderProp is returned as a non-CSS key, dropping the border.

Destructuring border into borderProp and then returning { borderProp } creates an invalid style key, so the border is lost when props.border is falsy.

🛠️ Suggested fix
-        return {
-          borderProp,
+        return {
+          border: borderProp,
           borderTop,
           borderRight,
           borderBottom,
           borderLeft,
           borderWidth,
           borderStyle: borderStyleProp,
           borderColor,
           borderRadius: borderRadiusProp,
shesha-reactjs/src/components/reactTable/styles/styles.ts (1)

445-505: ⚠️ Potential issue | 🟠 Major

Normalize numeric actionIconSize to CSS units.

actionIconSize is string | number, but template-literal CSS (antd-style createStyles) requires units for font-size, width, and height. If a number is passed, it produces unitless values like font-size: 16;, which is invalid CSS. Apply the normalization across all three icon styling blocks (.sha-link outer, .sha-link within .sha-crud-cell, and .sha-action-button).

🛠️ Suggested fix
+  const resolvedActionIconSize =
+    typeof actionIconSize === 'number' ? `${actionIconSize}px` : actionIconSize;
...
-                font-size: ${actionIconSize || bodyFontSize || '16px'};
-                width: ${actionIconSize || bodyFontSize || '16px'};
-                height: ${actionIconSize || bodyFontSize || '16px'};
-                min-width: ${actionIconSize || bodyFontSize || '16px'};
-                min-height: ${actionIconSize || bodyFontSize || '16px'};
+                font-size: ${resolvedActionIconSize || bodyFontSize || '16px'};
+                width: ${resolvedActionIconSize || bodyFontSize || '16px'};
+                height: ${resolvedActionIconSize || bodyFontSize || '16px'};
+                min-width: ${resolvedActionIconSize || bodyFontSize || '16px'};
+                min-height: ${resolvedActionIconSize || bodyFontSize || '16px'};

Apply the same resolvedActionIconSize replacement for all three icon blocks in this file.

🤖 Fix all issues with AI agents
In `@shesha-reactjs/src/components/reactTable/styles/styles.ts`:
- Around line 739-759: The flex container currently forces horizontal centering
with "justify-content: center" which ignores the bodyTextAlign prop; update the
auto rowHeight block (the styles around rowHeight and the cell flex rules) to
map bodyTextAlign to the flex "justify-content" value (e.g., left->flex-start,
center->center, right->flex-end, justify->space-between) while keeping vertical
centering via "align-items: center" (or "align-self: center" semantics used),
and retain the existing min-height/height/display rules and the vertical
separator ::after pseudo-element; use the rowHeight and bodyTextAlign variables
to compute the correct justify-content instead of the hardcoded center.

In `@shesha-reactjs/src/designer-components/dataTable/table/tableWrapper.tsx`:
- Around line 154-189: The background-size handling in effectiveBackground can
emit an invalid "/ size" token when bgStyles.backgroundSize exists but
bgStyles.backgroundPosition is absent; update the logic in the useMemo (function
effectiveBackground using getBackgroundStyle and bgStyles) to ensure a default
position is inserted before the "/" separator (e.g., use a default like "0% 0%"
or "center" when backgroundPosition is missing) and then build the combined
token as "<position> / <size>" instead of pushing "/ <size>" separately; keep
the early-return for color intact and only apply the default position when
composing image/position/size/repeat strings.

In `@shesha-reactjs/src/designer-components/dataTable/table/utils.ts`:
- Line 137: The return type in utils.ts declares actionIconSize as string but
must match the model ITableComponentBaseProps which defines actionIconSize as
string | number; update the returned type/signature and any related default
value or inferred type in the function or object that includes actionIconSize so
it is string | number (or cast the default to that union) to maintain type
consistency with ITableComponentBaseProps.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
shesha-reactjs/src/designer-components/dataTable/table/tableWrapper.tsx (1)

231-305: ⚠️ Potential issue | 🟠 Major

Border is dropped when props.border is falsy due to borderProp key.
The return object uses borderProp (not border), so the border is lost even when it should be preserved.

🛠️ Suggested fix
         return {
-          borderProp,
+          border: borderProp,
           borderTop,
           borderRight,
           borderBottom,
           borderLeft,
           borderWidth,
shesha-reactjs/src/components/reactTable/styles/styles.ts (1)

450-510: ⚠️ Potential issue | 🟡 Minor

Normalize numeric icon sizes to valid CSS units.
actionIconSize/bodyFontSize allow numbers; interpolating them directly yields unitless font-size/width/height and can be ignored by CSS. Normalize to px before use.

In CSS, do font-size/width/height accept unitless numbers, or must they include units like px?
🛠️ Suggested fix
+  const normalizeSize = (value?: string | number): string | undefined =>
+    typeof value === 'number' ? `${value}px` : value;
+
+  const actionIconSizeValue =
+    normalizeSize(actionIconSize) ?? normalizeSize(bodyFontSize) ?? '16px';
...
             .sha-link {
               .${iconPrefixCls} {
-                font-size: ${actionIconSize || bodyFontSize || '16px'};
-                width: ${actionIconSize || bodyFontSize || '16px'};
-                height: ${actionIconSize || bodyFontSize || '16px'};
-                min-width: ${actionIconSize || bodyFontSize || '16px'};
-                min-height: ${actionIconSize || bodyFontSize || '16px'};
+                font-size: ${actionIconSizeValue};
+                width: ${actionIconSizeValue};
+                height: ${actionIconSizeValue};
+                min-width: ${actionIconSizeValue};
+                min-height: ${actionIconSizeValue};
                 ${actionIconColor ? `color: ${actionIconColor};` : ''}
               }
             }
...
               .${iconPrefixCls} {
-                font-size: ${actionIconSize || bodyFontSize || '16px'};
-                width: ${actionIconSize || bodyFontSize || '16px'};
-                height: ${actionIconSize || bodyFontSize || '16px'};
-                min-width: ${actionIconSize || bodyFontSize || '16px'};
-                min-height: ${actionIconSize || bodyFontSize || '16px'};
+                font-size: ${actionIconSizeValue};
+                width: ${actionIconSizeValue};
+                height: ${actionIconSizeValue};
+                min-width: ${actionIconSizeValue};
+                min-height: ${actionIconSizeValue};
                 ${actionIconColor ? `color: ${actionIconColor};` : ''}
                 display: inline-flex;
                 align-items: center;
                 justify-content: center;
               }
...
               .${iconPrefixCls} {
-                font-size: ${actionIconSize || bodyFontSize || '16px'};
-                width: ${actionIconSize || bodyFontSize || '16px'};
-                height: ${actionIconSize || bodyFontSize || '16px'};
-                min-width: ${actionIconSize || bodyFontSize || '16px'};
-                min-height: ${actionIconSize || bodyFontSize || '16px'};
+                font-size: ${actionIconSizeValue};
+                width: ${actionIconSizeValue};
+                height: ${actionIconSizeValue};
+                min-width: ${actionIconSizeValue};
+                min-height: ${actionIconSizeValue};
                 ${actionIconColor ? `color: ${actionIconColor};` : ''}
                 display: inline-flex;
                 align-items: center;
                 justify-content: center;
               }

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
shesha-reactjs/src/components/reactTable/index.tsx (1)

201-219: 🧹 Nitpick | 🔵 Trivial

Consider stronger typing for overrideSelectedRow parameter.

The overrideSelectedRow parameter uses any for the row and id properties. Per coding guidelines, prefer unknown or a proper type over any to enforce explicit type checking.

♻️ Suggested type improvement
+interface ISelectedRowContext {
+  index: number;
+  row: unknown;
+  id: unknown;
+}
+
 const dispatchRowEvent = (
   actionConfig: IConfigurableActionConfiguration | undefined,
   rowData: any,
   rowIndex: number,
-  overrideSelectedRow?: { index: number; row: any; id: any },
+  overrideSelectedRow?: ISelectedRowContext,
 ): void => {
🤖 Fix all issues with AI agents
In `@shesha-reactjs/src/components/reactTable/index.tsx`:
- Around line 840-845: Replace the nested ternary that sets justifyContent using
effectiveHeaderTextAlign with a clear mapping object to improve readability:
create an alignMap (e.g., { center: 'center', right: 'flex-end', justify:
'space-between', left: 'flex-start' }) and use
alignMap[effectiveHeaderTextAlign] ?? 'flex-start' when assigning justifyContent
inside the component (where effectiveHeaderTextAlign and justifyContent are used
in the react table rendering). Ensure you reference effectiveHeaderTextAlign and
replace the ternary expression with the map lookup to keep behavior identical.

In `@shesha-reactjs/src/designer-components/dataTable/table/tableWrapper.tsx`:
- Around line 278-305: The return object mistakenly emits a property named
borderProp instead of restoring the original CSS property; change the returned
key from borderProp to border: borderProp so the original `border` value
(renamed to `borderProp` during destructuring) is reattached; update the object
in tableWrapper.tsx where `borderProp` is spread alongside other border fields
(the same place returning borderTop/Right/Bottom/Left etc.) so the `border` CSS
prop is preserved when props.border was falsy.

Comment on lines +840 to +845
// Map headerTextAlign to justify-content for flex container
justifyContent:
effectiveHeaderTextAlign === 'center' ? 'center'
: effectiveHeaderTextAlign === 'right' ? 'flex-end'
: effectiveHeaderTextAlign === 'justify' ? 'space-between'
: 'flex-start', // default for 'left' or undefined
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Consider extracting alignment mapping for readability.

The nested ternary is functional but could be clearer with a mapping object.

♻️ Optional refactor
+const alignmentToJustify: Record<string, string> = {
+  center: 'center',
+  right: 'flex-end',
+  justify: 'space-between',
+};
+
 // In the style object:
-justifyContent:
-  effectiveHeaderTextAlign === 'center' ? 'center'
-    : effectiveHeaderTextAlign === 'right' ? 'flex-end'
-      : effectiveHeaderTextAlign === 'justify' ? 'space-between'
-        : 'flex-start',
+justifyContent: alignmentToJustify[effectiveHeaderTextAlign] ?? 'flex-start',
🤖 Prompt for AI Agents
In `@shesha-reactjs/src/components/reactTable/index.tsx` around lines 840 - 845,
Replace the nested ternary that sets justifyContent using
effectiveHeaderTextAlign with a clear mapping object to improve readability:
create an alignMap (e.g., { center: 'center', right: 'flex-end', justify:
'space-between', left: 'flex-start' }) and use
alignMap[effectiveHeaderTextAlign] ?? 'flex-start' when assigning justifyContent
inside the component (where effectiveHeaderTextAlign and justifyContent are used
in the react table rendering). Ensure you reference effectiveHeaderTextAlign and
replace the ternary expression with the map lookup to keep behavior identical.

Comment on lines +278 to +305
return {
borderProp,
borderTop,
borderRight,
borderBottom,
borderLeft,
borderWidth,
borderStyle: borderStyleProp,
borderColor,
borderRadius: borderRadiusProp,
borderTopWidth,
borderRightWidth,
borderBottomWidth,
borderLeftWidth,
borderTopStyle,
borderRightStyle,
borderBottomStyle,
borderLeftStyle,
borderTopColor,
borderRightColor,
borderBottomColor,
borderLeftColor,
borderTopLeftRadius,
borderTopRightRadius,
borderBottomLeftRadius,
borderBottomRightRadius,
...styleWithoutBorderAndBackground,
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Bug: Property renamed incorrectly when re-spreading border properties.

Line 279 uses borderProp, which creates a property named borderProp instead of restoring the original border property. The destructuring at line 234 renames border to borderProp, but when re-adding it to the object, it should be border: borderProp,.

This causes the border CSS property to be lost when props.border is falsy.

🐛 Proposed fix
         // Remove background properties but keep border properties
         return {
-          borderProp,
+          border: borderProp,
           borderTop,
           borderRight,
           borderBottom,
           borderLeft,
           borderWidth,
           borderStyle: borderStyleProp,
           borderColor,
           borderRadius: borderRadiusProp,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return {
borderProp,
borderTop,
borderRight,
borderBottom,
borderLeft,
borderWidth,
borderStyle: borderStyleProp,
borderColor,
borderRadius: borderRadiusProp,
borderTopWidth,
borderRightWidth,
borderBottomWidth,
borderLeftWidth,
borderTopStyle,
borderRightStyle,
borderBottomStyle,
borderLeftStyle,
borderTopColor,
borderRightColor,
borderBottomColor,
borderLeftColor,
borderTopLeftRadius,
borderTopRightRadius,
borderBottomLeftRadius,
borderBottomRightRadius,
...styleWithoutBorderAndBackground,
};
return {
border: borderProp,
borderTop,
borderRight,
borderBottom,
borderLeft,
borderWidth,
borderStyle: borderStyleProp,
borderColor,
borderRadius: borderRadiusProp,
borderTopWidth,
borderRightWidth,
borderBottomWidth,
borderLeftWidth,
borderTopStyle,
borderRightStyle,
borderBottomStyle,
borderLeftStyle,
borderTopColor,
borderRightColor,
borderBottomColor,
borderLeftColor,
borderTopLeftRadius,
borderTopRightRadius,
borderBottomLeftRadius,
borderBottomRightRadius,
...styleWithoutBorderAndBackground,
};
🤖 Prompt for AI Agents
In `@shesha-reactjs/src/designer-components/dataTable/table/tableWrapper.tsx`
around lines 278 - 305, The return object mistakenly emits a property named
borderProp instead of restoring the original CSS property; change the returned
key from borderProp to border: borderProp so the original `border` value
(renamed to `borderProp` during destructuring) is reattached; update the object
in tableWrapper.tsx where `borderProp` is spread alongside other border fields
(the same place returning borderTop/Right/Bottom/Left etc.) so the `border` CSS
prop is preserved when props.border was falsy.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In `@shesha-reactjs/src/designer-components/dataTable/table/tableWrapper.tsx`:
- Around line 201-203: The code casts props.allStyles.fontStyles.fontSize to
string before parseInt which can hide non-string values; update the fontSize
assignment in tableWrapper.tsx to first read const fs =
props?.allStyles?.fontStyles?.fontSize and then use a type guard: if typeof fs
=== 'string' parseInt(fs, 10), else if typeof fs === 'number' use fs, otherwise
fall back to props?.font?.size; replace the existing
parseInt(props.allStyles.fontStyles.fontSize as string, 10) expression with this
guarded logic to avoid NaN and unsafe casts.
- Around line 150-156: In the useMemo block that computes effectiveBodyTextAlign
(the memoized function in tableWrapper.tsx), remove the debug console.log("table
styles", props?.allStyles) so no debug output is emitted; keep the rest of the
useMemo logic that returns props?.allStyles?.fontStyles?.textAlign ??
props?.font?.align and retain the dependency array
[props?.allStyles?.fontStyles?.textAlign, props?.font?.align].
- Around line 529-531: The bodyFontSize prop in tableWrapper.tsx currently
force-casts props.allStyles.fontStyles.fontSize to string which is unsafe;
update the expression (used alongside useStyles) to use a type guard: check if
props?.allStyles?.fontStyles?.fontSize is a string then use it, else if it's a
number convert it to `${value}px`, otherwise fall back to props?.font?.size
similarly converted; mirror the same safe handling logic used in useStyles so
fontSize is consistently and safely resolved without blind type assertions.

Comment on lines +201 to +203
fontSize: props?.allStyles?.fontStyles?.fontSize
? parseInt(props.allStyles.fontStyles.fontSize as string, 10)
: props?.font?.size,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Prefer type guard over type cast for fontSize.

The as string cast bypasses type checking. If fontSize isn't a string at runtime, parseInt may produce NaN. Per coding guidelines, use a type guard to safely check the value before parsing.

♻️ Suggested refactor
-    fontSize: props?.allStyles?.fontStyles?.fontSize
-      ? parseInt(props.allStyles.fontStyles.fontSize as string, 10)
-      : props?.font?.size,
+    fontSize: typeof props?.allStyles?.fontStyles?.fontSize === 'string'
+      ? parseInt(props.allStyles.fontStyles.fontSize, 10)
+      : typeof props?.allStyles?.fontStyles?.fontSize === 'number'
+        ? props.allStyles.fontStyles.fontSize
+        : props?.font?.size,
🤖 Prompt for AI Agents
In `@shesha-reactjs/src/designer-components/dataTable/table/tableWrapper.tsx`
around lines 201 - 203, The code casts props.allStyles.fontStyles.fontSize to
string before parseInt which can hide non-string values; update the fontSize
assignment in tableWrapper.tsx to first read const fs =
props?.allStyles?.fontStyles?.fontSize and then use a type guard: if typeof fs
=== 'string' parseInt(fs, 10), else if typeof fs === 'number' use fs, otherwise
fall back to props?.font?.size; replace the existing
parseInt(props.allStyles.fontStyles.fontSize as string, 10) expression with this
guarded logic to avoid NaN and unsafe casts.

Comment on lines +529 to +531
bodyFontSize={props?.allStyles?.fontStyles?.fontSize
? (props.allStyles.fontStyles.fontSize as string)
: (props?.font?.size ? `${props.font.size}px` : undefined)}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Apply consistent type handling for fontSize.

Same type cast issue as in useStyles. Use a type guard for consistency and safety.

♻️ Suggested refactor
-            bodyFontSize={props?.allStyles?.fontStyles?.fontSize
-              ? (props.allStyles.fontStyles.fontSize as string)
-              : (props?.font?.size ? `${props.font.size}px` : undefined)}
+            bodyFontSize={typeof props?.allStyles?.fontStyles?.fontSize === 'string'
+              ? props.allStyles.fontStyles.fontSize
+              : typeof props?.allStyles?.fontStyles?.fontSize === 'number'
+                ? `${props.allStyles.fontStyles.fontSize}px`
+                : (props?.font?.size ? `${props.font.size}px` : undefined)}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
bodyFontSize={props?.allStyles?.fontStyles?.fontSize
? (props.allStyles.fontStyles.fontSize as string)
: (props?.font?.size ? `${props.font.size}px` : undefined)}
bodyFontSize={typeof props?.allStyles?.fontStyles?.fontSize === 'string'
? props.allStyles.fontStyles.fontSize
: typeof props?.allStyles?.fontStyles?.fontSize === 'number'
? `${props.allStyles.fontStyles.fontSize}px`
: (props?.font?.size ? `${props.font.size}px` : undefined)}
🤖 Prompt for AI Agents
In `@shesha-reactjs/src/designer-components/dataTable/table/tableWrapper.tsx`
around lines 529 - 531, The bodyFontSize prop in tableWrapper.tsx currently
force-casts props.allStyles.fontStyles.fontSize to string which is unsafe;
update the expression (used alongside useStyles) to use a type guard: check if
props?.allStyles?.fontStyles?.fontSize is a string then use it, else if it's a
number convert it to `${value}px`, otherwise fall back to props?.font?.size
similarly converted; mirror the same safe handling logic used in useStyles so
fontSize is consistently and safely resolved without blind type assertions.

@James-Baloyi James-Baloyi merged commit 6e01901 into shesha-io:main Feb 2, 2026
2 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Feb 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant