Skip to content

Commit

Permalink
fix(app): use Keyboard.onInit hook to set the initial value of the ke…
Browse files Browse the repository at this point in the history
…yboard. (#16147)
  • Loading branch information
vegano1 authored Aug 28, 2024
1 parent cd1a05b commit b3ad084
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/src/atoms/SoftwareKeyboard/NumericalKeyboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ interface NumericalKeyboardProps {
isDecimal?: boolean
hasHyphen?: boolean
debug?: boolean
initialValue?: string
}

// the default keyboard layout intKeyboard that doesn't have decimal point and hyphen.
Expand All @@ -22,6 +23,7 @@ export function NumericalKeyboard({
isDecimal = false,
hasHyphen = false,
debug = false,
initialValue = '',
}: NumericalKeyboardProps): JSX.Element {
const layoutName = `${isDecimal ? 'float' : 'int'}${
hasHyphen ? 'NegKeyboard' : 'Keyboard'
Expand All @@ -35,6 +37,7 @@ export function NumericalKeyboard({
<Keyboard
keyboardRef={r => (keyboardRef.current = r)}
theme={'hg-theme-default oddTheme1 numerical-keyboard'}
onInit={keyboard => {keyboard.setInput(initialValue)}}
onChange={onChange}
display={numericalCustom}
useButtonTag={true}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ export function AirGap(props: AirGapProps): JSX.Element {
>
<NumericalKeyboard
keyboardRef={keyboardRef}
initialValue={String(volume)}
onChange={e => {
setVolume(Number(e))
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ export function Delay(props: DelayProps): JSX.Element {
>
<NumericalKeyboard
keyboardRef={keyboardRef}
initialValue={String(position)}
onChange={e => {
setPosition(Number(e))
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export function FlowRateEntry(props: FlowRateEntryProps): JSX.Element {
>
<NumericalKeyboard
keyboardRef={keyboardRef}
initialValue={String(flowRate)}
onChange={e => {
setFlowRate(Number(e))
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ export function Mix(props: MixProps): JSX.Element {
>
<NumericalKeyboard
keyboardRef={keyboardRef}
initialValue={String(mixVolume)}
onChange={e => {
setMixVolume(Number(e))
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ export function PipettePath(props: PipettePathProps): JSX.Element {
>
<NumericalKeyboard
keyboardRef={keyboardRef}
initialValue={String(disposalVolume)}
onChange={e => {
setDisposalVolume(Number(e))
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ export function TipPositionEntry(props: TipPositionEntryProps): JSX.Element {
>
<NumericalKeyboard
keyboardRef={keyboardRef}
initialValue={String(tipPosition)}
onChange={e => {
setTipPosition(Number(e))
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ export function TouchTip(props: TouchTipProps): JSX.Element {
>
<NumericalKeyboard
keyboardRef={keyboardRef}
initialValue={String(position)}
onChange={e => {
setPosition(Number(e))
}}
Expand Down

0 comments on commit b3ad084

Please sign in to comment.