Fixed open table cell triggering (#6910)

Open table cell was triggered by a click on a field input.

This is a temporary solution.

I fixed it for DoubleTextInput but it might be problematic for other
field types as well, we should implement a kind of bubbling shield to
make sure that no click event can bubble up to trigger things like open
table cell in the above components that shouldn't listen.

See https://github.com/twentyhq/twenty/issues/6909
This commit is contained in:
Lucas Bordeau 2024-09-06 10:23:27 +02:00 committed by GitHub
parent 338298e14b
commit b9ee313923
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -172,6 +172,13 @@ export const DoubleTextInput = ({
onPaste?.({ firstValue: splittedName[0], secondValue: splittedName[1] });
};
const handleClickToPreventParentClickEvents = (
event: React.MouseEvent<HTMLInputElement>,
) => {
event.stopPropagation();
event.preventDefault();
};
return (
<StyledContainer ref={containerRef}>
<StyledTextInput
@ -187,6 +194,7 @@ export const DoubleTextInput = ({
onPaste={(event: ClipboardEvent<HTMLInputElement>) =>
handleOnPaste(event)
}
onClick={handleClickToPreventParentClickEvents}
/>
<StyledTextInput
autoComplete="off"
@ -197,6 +205,7 @@ export const DoubleTextInput = ({
onChange={(event: ChangeEvent<HTMLInputElement>) => {
handleChange(firstInternalValue, event.target.value);
}}
onClick={handleClickToPreventParentClickEvents}
/>
</StyledContainer>
);