Skip to content

Commit

Permalink
Prevent default on pointerdown
Browse files Browse the repository at this point in the history
  • Loading branch information
joel-jeremy committed Sep 25, 2023
1 parent f75c06c commit a1561e7
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,11 @@ function BudgetCell({
}

return (
<View style={style} onPointerUp={onAmountClick}>
<View
style={style}
onPointerUp={onAmountClick}
onPointerDown={e => e.preventDefault()}
>
{editing ? (
<AmountInput
initialValue={sheetValue}
Expand Down
56 changes: 22 additions & 34 deletions packages/desktop-client/src/components/spreadsheet/CellValue.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useMemo, type ReactNode } from 'react';
import React, { type ReactNode } from 'react';

import { type CSSProperties, styles } from '../../style';
import Text from '../common/Text';
Expand Down Expand Up @@ -36,40 +36,28 @@ function CellValue({
let sheetValue = useSheetValue(binding);
let format = useFormat();

return useMemo(
() => (
<ConditionalPrivacyFilter
privacyFilter={
privacyFilter != null
? privacyFilter
: type === 'financial'
? true
: undefined
}
return (
<ConditionalPrivacyFilter
privacyFilter={
privacyFilter != null
? privacyFilter
: type === 'financial'
? true
: undefined
}
>
<Text
style={{
...(type === 'financial' && styles.tnum),
...style,
...(getStyle && getStyle(sheetValue)),
}}
data-testid={testId || fullSheetName}
data-cellname={fullSheetName}
>
<Text
style={{
...(type === 'financial' && styles.tnum),
...style,
...(getStyle && getStyle(sheetValue)),
}}
data-testid={testId || fullSheetName}
data-cellname={fullSheetName}
>
{formatter ? formatter(sheetValue) : format(sheetValue, type)}
</Text>
</ConditionalPrivacyFilter>
),
[
privacyFilter,
type,
style,
getStyle,
fullSheetName,
formatter,
format,
sheetValue,
],
{formatter ? formatter(sheetValue) : format(sheetValue, type)}
</Text>
</ConditionalPrivacyFilter>
);
}

Expand Down
6 changes: 3 additions & 3 deletions packages/desktop-client/src/components/util/AmountInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function AmountInput({
let [value, setValue] = useState(initialValueAbsolute);
let ref = useRef();
let buttonRef = useRef();
let mergedRef = useMergedRefs(inputRef, ref);
let mergedInputRef = useMergedRefs(inputRef, ref);

function onSwitch() {
ref.current?.focus();
Expand Down Expand Up @@ -59,13 +59,13 @@ export function AmountInput({
return (
<InputWithContent
id={id}
inputRef={mergedRef}
inputRef={mergedInputRef}
inputMode="decimal"
leftContent={
<Button
type="bare"
style={{ padding: '0 7px' }}
onClick={onSwitch}
onPointerUp={onSwitch}
onPointerDown={e => e.preventDefault()}
ref={buttonRef}
>
Expand Down

0 comments on commit a1561e7

Please sign in to comment.