Skip to content

TPS-1105: allow single select field to select from booleans 🚨do not merge#57

Open
mad-raccoon wants to merge 1 commit intomainfrom
TPS-1105_boolean_selection
Open

TPS-1105: allow single select field to select from booleans 🚨do not merge#57
mad-raccoon wants to merge 1 commit intomainfrom
TPS-1105_boolean_selection

Conversation

@mad-raccoon
Copy link
Collaborator

@mad-raccoon mad-raccoon commented Jan 21, 2026

Why is this pull-request needed?

This PR allows the Single and Multi Selectfield to work with strings, numbers and booleans.

This is an hotfix - we will need to go back on Remarkable ui and improve the types later.

If merged, please make sure it is properly tested.

After merged, a Version PR will be created on the Pull Requests tab. After that is approved and merged, a new version will be created, and we can tell the client this was sorted.

Test evidence

Screen.Recording.2026-01-21.at.16.11.27.mov

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Fixed SingleSelectField to properly handle and select from boolean options.
    • Improved handling of empty strings, zeros, and false values across form components and chart interactions.
  • New Features

    • Expanded SingleSelectField, MultiSelectField, GranularitySelectField, and DateRangePickerPresets to support boolean, numeric, and undefined option values.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 21, 2026

Walkthrough

This PR adds changeset entries documenting fixes for boolean support in SingleSelectField, bumps the remarkable-ui dependency version, and systematically replaces logical OR operators with nullish coalescing operators across chart and form field components. Additionally, prop type signatures are expanded to accept boolean, number, and undefined values alongside strings for improved type safety.

Changes

Cohort / File(s) Summary
Changeset Entries
.changeset/late-laws-follow.md, .changeset/tender-berries-hug.md
Two changeset files documenting patch releases for @embeddable.com/remarkable-pro with fixes/features for boolean options in SingleSelectField.
Dependency Update
package.json
Bumped @embeddable.com/remarkable-ui from ^2.0.29 to ^2.0.30.
Bar Chart Components
src/components/charts/bars/BarChart*Pro/*.emb.ts
Replaced logical OR with nullish coalescing (??) for axisDimensionValue and groupingDimensionValue in onBarClicked handlers across 6 chart variants (Default, DefaultHorizontal, Grouped, GroupedHorizontal, Stacked, StackedHorizontal).
Line Chart Components
src/components/charts/lines/LineChart*Pro/*.emb.ts
Replaced logical OR with nullish coalescing (??) for dimensionValue and groupingDimensionValue in onLineClicked handlers across 3 chart variants (Default, DefaultComparison, Grouped).
Pie/Donut Chart Components
src/components/charts/pies/*ChartPro/*.emb.ts
Replaced logical OR with nullish coalescing (??) for dimensionValue in onSegmentClick handlers across 4 components (DonutChart, DonutLabelChart, PieChart).
Form Field Type Expansions
src/components/editors/ComparisonPeriodSelectFieldPro/index.tsx, src/components/editors/GranularitySelectFieldPro/index.tsx, src/components/editors/MultiSelectFieldPro/index.tsx
Expanded onChange callback parameter types from single string to union of string | boolean | number | undefined with TODO comments.
SingleSelectFieldPro Updates
src/components/editors/SingleSelectFieldPro/SingleSelectFieldPro.emb.ts, src/components/editors/SingleSelectFieldPro/index.tsx
Expanded onChange callback type to accept number | string | boolean | undefined. Added boolean-aware value handling with computed selectedValueIsBoolean and safeValue mapping logic in index.tsx (+22/-4).
Date Range Picker Updates
src/components/editors/dates/DateRangePickerPresetsPro/index.tsx
Updated handleOptionChange type to accept string | number | boolean | undefined and changed Key props to use .toString() for compatibility with non-string values.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The description covers the 'Why' and 'Test evidence' sections, though the 'Main changes' section lacks detail about specific implementation changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title accurately reflects the main change: enabling SingleSelectField to accept boolean values alongside strings and numbers, as evidenced by widespread updates across select field components.

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

✨ Finishing touches
  • 📝 Generate docstrings

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

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
14.5% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

Copy link

@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 (1)
src/components/editors/MultiSelectFieldPro/index.tsx (1)

13-21: Align selectedValues with widened option types.

onChange now supports boolean/number values, but selectedValues is still string[], so callers can’t pass non-string selections and values becomes type-inconsistent. Widen selectedValues to the same union.

🛠️ Suggested fix
 type MultiSelectFieldProProps = {
   dimension: Dimension;
   optionalSecondDimension?: Dimension;
   placeholder?: string;
   results: DataResponse;
-  selectedValues?: string[];
+  selectedValues?: (string | number | boolean | undefined)[];
   maxOptions?: number;
   setSearchValue?: (search: string) => void;
   onChange?: (newValues: (string | number | boolean | undefined)[]) => void;
 } & ChartCardHeaderProps;
🤖 Fix all issues with AI agents
In `@src/components/editors/SingleSelectFieldPro/index.tsx`:
- Line 66: Remove the debug console.log that prints selectedValue and safeValue
inside the SingleSelectFieldPro component: locate the stray
console.log('selectedValue', selectedValue, safeValue) and delete it (or replace
it with a proper non-user-data-producing debug log behind an env-level debug
flag if you need runtime diagnostics), ensuring no user data is written to
stdout/stderr.
- Around line 53-64: The safeValue lookup currently turns an already-boolean
selectedValue into undefined and doesn't handle numeric-string coercion; update
the safeValue computation (the block using selectedValueIsBoolean,
optionalSecondDimension, dimension, selectedValue, and options) to coerce
selectedValue into the option value type instead of forcing undefined: if
selectedValueIsBoolean is true, accept true/false values and also the strings
'true'/'false' (preserve booleans if already boolean); if the matched option
values are numbers, coerce numeric strings to numbers (Number or parseFloat)
before comparison; otherwise compare using strict equality to find the matching
option.value and return that value for safeValue.

In `@src/components/editors/SingleSelectFieldPro/SingleSelectFieldPro.emb.ts`:
- Around line 110-112: The meta declarations for this component are out of sync
with the onChange handler: onChange accepts number | string | boolean |
undefined but meta.events and meta.variables still declare the type as 'string';
update the metadata to reflect the broader union type (or a generic 'any' if
preferred) so emitted event payloads and variable typings match onChange's
signature—locate meta.events and meta.variables in SingleSelectFieldPro.emb.ts
and change their type from 'string' to the union type (number | string | boolean
| undefined) or a compatible type to align with onChange and Value.noFilter()
handling.
🧹 Nitpick comments (1)
src/components/editors/SingleSelectFieldPro/index.tsx (1)

13-21: Widen selectedValue type to match new supported values.

onChange now emits boolean/number, but selectedValue is still typed as string, which prevents passing these values back in and forces unsafe casts.

♻️ Suggested type update
 type SingleSelectFieldProProps = {
   dimension: Dimension;
   optionalSecondDimension?: Dimension;
   placeholder?: string;
   results: DataResponse;
-  selectedValue?: string;
+  selectedValue?: string | boolean | number;
   maxOptions?: number;
   setSearchValue?: (search: string) => void;
   onChange?: (selectedValue: string | boolean | number | undefined) => void;
 } & ChartCardHeaderProps;

Comment on lines +53 to +64
const selectedValueIsBoolean = optionalSecondDimension
? optionalSecondDimension.nativeType === 'boolean'
: dimension.nativeType === 'boolean';

const safeValue = options.find((option) => {
let value: string | boolean | undefined = selectedValue;
if (selectedValueIsBoolean) {
value = selectedValue === 'true' ? true : selectedValue === 'false' ? false : undefined;
}

return option.value === value;
})?.value;
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

safeValue drops boolean inputs and doesn’t coerce numeric strings.

If selectedValue is already a boolean, the current logic turns it into undefined. Also, numeric selections won’t preselect when selectedValue is a string (common given the selectedValue input). This breaks preselection for boolean and numeric options.

🐛 Suggested fix for boolean + numeric handling
-  const selectedValueIsBoolean = optionalSecondDimension
+  const selectedValueIsBoolean = optionalSecondDimension
     ? optionalSecondDimension.nativeType === 'boolean'
     : dimension.nativeType === 'boolean';
+
+  const selectedValueIsNumber = optionalSecondDimension
+    ? optionalSecondDimension.nativeType === 'number'
+    : dimension.nativeType === 'number';

   const safeValue = options.find((option) => {
-    let value: string | boolean | undefined = selectedValue;
+    let value: string | boolean | number | undefined = selectedValue;
     if (selectedValueIsBoolean) {
-      value = selectedValue === 'true' ? true : selectedValue === 'false' ? false : undefined;
+      if (selectedValue === true || selectedValue === false) {
+        value = selectedValue;
+      } else if (selectedValue === 'true') {
+        value = true;
+      } else if (selectedValue === 'false') {
+        value = false;
+      } else {
+        value = undefined;
+      }
+    } else if (selectedValueIsNumber && typeof selectedValue === 'string') {
+      const parsed = Number(selectedValue);
+      value = Number.isNaN(parsed) ? undefined : parsed;
     }

     return option.value === value;
   })?.value;
🤖 Prompt for AI Agents
In `@src/components/editors/SingleSelectFieldPro/index.tsx` around lines 53 - 64,
The safeValue lookup currently turns an already-boolean selectedValue into
undefined and doesn't handle numeric-string coercion; update the safeValue
computation (the block using selectedValueIsBoolean, optionalSecondDimension,
dimension, selectedValue, and options) to coerce selectedValue into the option
value type instead of forcing undefined: if selectedValueIsBoolean is true,
accept true/false values and also the strings 'true'/'false' (preserve booleans
if already boolean); if the matched option values are numbers, coerce numeric
strings to numbers (Number or parseFloat) before comparison; otherwise compare
using strict equality to find the matching option.value and return that value
for safeValue.

return option.value === value;
})?.value;

console.log('selectedValue', selectedValue, safeValue);
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove the debug console.log.

This will leak user data into logs and adds noise in production.

🤖 Prompt for AI Agents
In `@src/components/editors/SingleSelectFieldPro/index.tsx` at line 66, Remove the
debug console.log that prints selectedValue and safeValue inside the
SingleSelectFieldPro component: locate the stray console.log('selectedValue',
selectedValue, safeValue) and delete it (or replace it with a proper
non-user-data-producing debug log behind an env-level debug flag if you need
runtime diagnostics), ensuring no user data is written to stdout/stderr.

Comment on lines +110 to +112
onChange: (selectedValue: number | string | boolean | undefined) => {
return {
value: selectedValue || Value.noFilter(),
value: selectedValue ?? Value.noFilter(),
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

find . -type f -name "SingleSelectFieldPro.emb.ts" | head -5

Repository: embeddable-hq/remarkable-pro

Length of output: 145


🏁 Script executed:

cat -n src/components/editors/SingleSelectFieldPro/SingleSelectFieldPro.emb.ts

Repository: embeddable-hq/remarkable-pro

Length of output: 4041


🏁 Script executed:

# Search for meta.events, meta.variables, and inputs definitions in the file
rg "meta\.(events|variables|inputs)" src/components/editors/SingleSelectFieldPro/SingleSelectFieldPro.emb.ts -A 3

Repository: embeddable-hq/remarkable-pro

Length of output: 54


Update meta.events and meta.variables to match the broader onChange input type.

onChange now accepts number | string | boolean | undefined, but the metadata still declares the event property and variable type as 'string'. While this may work for string values, it'll cause type mismatches if the component receives or emits non-string values. Align the metadata types (lines 57, 65) with the handler's accepted types to avoid downstream confusion.

🤖 Prompt for AI Agents
In `@src/components/editors/SingleSelectFieldPro/SingleSelectFieldPro.emb.ts`
around lines 110 - 112, The meta declarations for this component are out of sync
with the onChange handler: onChange accepts number | string | boolean |
undefined but meta.events and meta.variables still declare the type as 'string';
update the metadata to reflect the broader union type (or a generic 'any' if
preferred) so emitted event payloads and variable typings match onChange's
signature—locate meta.events and meta.variables in SingleSelectFieldPro.emb.ts
and change their type from 'string' to the union type (number | string | boolean
| undefined) or a compatible type to align with onChange and Value.noFilter()
handling.

@mad-raccoon mad-raccoon changed the title TPS-1105: allow single select field to select from booleans TPS-1105: allow single select field to select from booleans 🚨do not merge Jan 21, 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