Skip to content

Commit f485253

Browse files
Modify precision to work for -1 value
1 parent 17c13ef commit f485253

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

src/ui/widgets/Input/input.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@ export const SmartInputComponent = (
9191

9292
// Decide what to display.
9393
const display = value?.getDisplay();
94-
const prec = precisionFromPv ? (display?.precision ?? precision) : precision;
94+
// In Phoebus, default precision -1 seems to usually be 3. The toFixed functions
95+
// cannot accept -1 as a valid answer
96+
let prec = precisionFromPv ? (display?.precision ?? precision) : precision;
97+
if (prec === -1) prec = 3;
9598

9699
let displayedValue;
97100
if (!value) {

src/ui/widgets/ProgressBar/progressBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export const ProgressBarComponent = (
6868
label = "Check min and max values";
6969
} else {
7070
if (precision) {
71-
label = numValue.toFixed(precision);
71+
label = numValue.toFixed(precision === -1 ? 3 : precision);
7272
} else {
7373
label = numValue.toString();
7474
}

src/ui/widgets/Readback/readback.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ export const ReadbackComponent = (
9999

100100
// Decide what to display.
101101
const display = value?.getDisplay();
102-
const prec = precisionFromPv ? (display?.precision ?? precision) : precision;
102+
// In Phoebus, default precision -1 seems to usually be 3. The toFixed functions
103+
// cannot accept -1 as a valid answer
104+
let prec = precisionFromPv ? (display?.precision ?? precision) : precision;
105+
if (prec === -1) prec = 3;
103106

104107
let displayedValue;
105108
if (!value) {

0 commit comments

Comments
 (0)