Skip to content

Commit 2cc1ec4

Browse files
Address review feedback: skip hex components in finalizeValues
An all-decimal-digit hex string (e.g. 000000) parses fine as a Double, so finalizeValues was reformatting it through formattedDragValue's .hex case, which always returns "" — blanking the field on commit.
1 parent 81fe9f9 commit 2cc1ec4

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

Pika/Views/EditableColorValue.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,10 +429,13 @@ struct EditableColorValue: View {
429429
/// Snaps any component whose typed value fell outside its range to the nearest bound, and
430430
/// restrips every numeric value's trailing zeros back to its normal compact form — undoing
431431
/// the fixed-decimal-places padding a scrub session keeps live (see `formattedDragValue`) now
432-
/// that it's ending. Hex is skipped naturally: it doesn't parse as a `Double`.
432+
/// that it's ending. Hex is skipped explicitly: an all-decimal-digit hex string (e.g.
433+
/// `000000`) parses fine as a `Double`, and `formattedDragValue`'s `.hex` case always returns
434+
/// `""`, which would blank the field.
433435
private func finalizeValues(layout: DecomposedColor) {
434436
for (i, component) in layout.components.enumerated() where i < values.count {
435-
guard let n = Double(values[i].trimmingCharacters(in: .whitespaces)) else { continue }
437+
guard component.kind != .hex,
438+
let n = Double(values[i].trimmingCharacters(in: .whitespaces)) else { continue }
436439
let clamped = component.range.map { min(max(n, $0.lowerBound), $0.upperBound) } ?? n
437440
values[i] = ColorComponentField.formattedDragValue(clamped, kind: component.kind)
438441
}

0 commit comments

Comments
 (0)