Skip to content

fix(web-frontend): Handle non-string values in InlineEdit.trim()#18

Draft
sentry[bot] wants to merge 1 commit into
devfrom
seer/fix/inline-edit-typeerror
Draft

fix(web-frontend): Handle non-string values in InlineEdit.trim()#18
sentry[bot] wants to merge 1 commit into
devfrom
seer/fix/inline-edit-typeerror

Conversation

@sentry

@sentry sentry Bot commented May 22, 2026

Copy link
Copy Markdown
Contributor

This PR addresses a TypeError: valueToDisplay.trim is not a function occurring in InlineEdit.tsx.

Root Cause:
The InlineEdit component expected value and displayValue props to always be strings. However, when displaying Person.id from the backend, which can be an int | str, a numeric ID would be passed as a JavaScript number. If TableColumns rendered InlineEdit for item.id without a prefix, this number would flow directly to valueToDisplay, causing .trim() to fail.

Solution:

  1. Widened Prop Types: Updated InlineEditProps to allow value and displayValue to be string | number | null | undefined.
  2. Safe String Coercion: Modified the calculation of valueToDisplay to String(displayValue ?? value ?? '') to ensure .trim() is always called on a string.
  3. Hardened Edit Mode: Applied similar string coercion to the defaultValue of the input field and within the handleSave function to prevent crashes when editing numeric values or potentially null/undefined descriptions.

Fixes NURSE-SCHEDULING-7

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.

0 participants