From c8011da4d7202220d3ec4730cc18101eb537ad9b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rapha=C3=ABl=20Bosi?=
<71827178+bosiraphael@users.noreply.github.com>
Date: Fri, 11 Apr 2025 14:22:31 +0200
Subject: [PATCH] Fix title input hotkey scope (#11530)
Before:
https://github.com/user-attachments/assets/e0be8247-6d3e-49d0-8595-76f9547bf354
After:
https://github.com/user-attachments/assets/ae23b01b-3ad7-4b90-b4ae-ce604d984d73
---
.../components/RecordTitleCellFieldInput.tsx | 6 +++---
.../RecordTitleCellTextFieldDisplay.tsx | 16 +++++++++++++++-
.../hooks/useRecordTitleCell.tsx | 4 ++--
.../ui/input/types/TitleInputHotkeyScope.ts | 3 +++
4 files changed, 23 insertions(+), 6 deletions(-)
create mode 100644 packages/twenty-front/src/modules/ui/input/types/TitleInputHotkeyScope.ts
diff --git a/packages/twenty-front/src/modules/object-record/record-title-cell/components/RecordTitleCellFieldInput.tsx b/packages/twenty-front/src/modules/object-record/record-title-cell/components/RecordTitleCellFieldInput.tsx
index cb2885c51..2a499f08c 100644
--- a/packages/twenty-front/src/modules/object-record/record-title-cell/components/RecordTitleCellFieldInput.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-title-cell/components/RecordTitleCellFieldInput.tsx
@@ -4,9 +4,9 @@ import { FieldContext } from '@/object-record/record-field/contexts/FieldContext
import { FieldInputEvent } from '@/object-record/record-field/types/FieldInputEvent';
import { isFieldFullName } from '@/object-record/record-field/types/guards/isFieldFullName';
import { isFieldText } from '@/object-record/record-field/types/guards/isFieldText';
-import { DEFAULT_CELL_SCOPE } from '@/object-record/record-table/record-table-cell/hooks/useOpenRecordTableCellV2';
import { RecordTitleCellTextFieldInput } from '@/object-record/record-title-cell/components/RecordTitleCellTextFieldInput';
import { RecordTitleFullNameFieldInput } from '@/object-record/record-title-cell/components/RecordTitleFullNameFieldInput';
+import { TitleInputHotkeyScope } from '@/ui/input/types/TitleInputHotkeyScope';
type RecordTitleCellFieldInputProps = {
onClickOutside?: (
@@ -44,7 +44,7 @@ export const RecordTitleCellFieldInput = ({
onTab={onTab}
onShiftTab={onShiftTab}
sizeVariant={sizeVariant}
- hotkeyScope={DEFAULT_CELL_SCOPE.scope}
+ hotkeyScope={TitleInputHotkeyScope.TitleInput}
/>
) : isFieldFullName(fieldDefinition) ? (
) : null}
>
diff --git a/packages/twenty-front/src/modules/object-record/record-title-cell/components/RecordTitleCellTextFieldDisplay.tsx b/packages/twenty-front/src/modules/object-record/record-title-cell/components/RecordTitleCellTextFieldDisplay.tsx
index ce6126793..d7ff5ebdc 100644
--- a/packages/twenty-front/src/modules/object-record/record-title-cell/components/RecordTitleCellTextFieldDisplay.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-title-cell/components/RecordTitleCellTextFieldDisplay.tsx
@@ -1,6 +1,9 @@
import { FieldContext } from '@/object-record/record-field/contexts/FieldContext';
+import { INLINE_CELL_HOTKEY_SCOPE_MEMOIZE_KEY } from '@/object-record/record-inline-cell/constants/InlineCellHotkeyScopeMemoizeKey';
import { useInlineCell } from '@/object-record/record-inline-cell/hooks/useInlineCell';
import { useRecordValue } from '@/object-record/record-store/contexts/RecordFieldValueSelectorContext';
+import { TitleInputHotkeyScope } from '@/ui/input/types/TitleInputHotkeyScope';
+import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousHotkeyScope';
import styled from '@emotion/styled';
import { useContext } from 'react';
import { OverflowingTextWithTooltip } from 'twenty-ui/display';
@@ -30,8 +33,19 @@ export const RecordTitleCellSingleTextDisplayMode = () => {
const { openInlineCell } = useInlineCell();
+ const { setHotkeyScopeAndMemorizePreviousScope } = usePreviousHotkeyScope(
+ INLINE_CELL_HOTKEY_SCOPE_MEMOIZE_KEY,
+ );
+
return (
- openInlineCell()}>
+ {
+ setHotkeyScopeAndMemorizePreviousScope(
+ TitleInputHotkeyScope.TitleInput,
+ );
+ openInlineCell();
+ }}
+ >
{
);
} else {
setHotkeyScopeAndMemorizePreviousScope(
- InlineCellHotkeyScope.InlineCell,
+ TitleInputHotkeyScope.TitleInput,
);
}
},
diff --git a/packages/twenty-front/src/modules/ui/input/types/TitleInputHotkeyScope.ts b/packages/twenty-front/src/modules/ui/input/types/TitleInputHotkeyScope.ts
new file mode 100644
index 000000000..4f265fa3b
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/input/types/TitleInputHotkeyScope.ts
@@ -0,0 +1,3 @@
+export enum TitleInputHotkeyScope {
+ TitleInput = 'title-input',
+}