Skip to content

The open alternative to Salesforce, designed for AI.

Fix title input hotkey scope (#11530)

Raphaël Bosic8011da4d720
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 cb2885c513d..2a499f08c01 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) ? (
<RecordTitleFullNameFieldInput
@@ -54,7 +54,7 @@ export const RecordTitleCellFieldInput = ({
onTab={onTab}
onShiftTab={onShiftTab}
sizeVariant={sizeVariant}
- hotkeyScope={DEFAULT_CELL_SCOPE.scope}
+ hotkeyScope={TitleInputHotkeyScope.TitleInput}
/>
) : 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 ce612679389..d7ff5ebdc34 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 (
- <StyledDiv onClick={() => openInlineCell()}>
+ <StyledDiv
+ onClick={() => {
+ setHotkeyScopeAndMemorizePreviousScope(
+ TitleInputHotkeyScope.TitleInput,
+ );
+ openInlineCell();
+ }}
+ >
<OverflowingTextWithTooltip
text={
recordValue?.[fieldDefinition.metadata.fieldName] ||
diff --git a/packages/twenty-front/src/modules/object-record/record-title-cell/hooks/useRecordTitleCell.tsx b/packages/twenty-front/src/modules/object-record/record-title-cell/hooks/useRecordTitleCell.tsx
index acab2bd518c..2e0c1e60b85 100644
--- a/packages/twenty-front/src/modules/object-record/record-title-cell/hooks/useRecordTitleCell.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-title-cell/hooks/useRecordTitleCell.tsx
@@ -1,7 +1,7 @@
import { INLINE_CELL_HOTKEY_SCOPE_MEMOIZE_KEY } from '@/object-record/record-inline-cell/constants/InlineCellHotkeyScopeMemoizeKey';
import { isInlineCellInEditModeScopedState } from '@/object-record/record-inline-cell/states/isInlineCellInEditModeScopedState';
-import { InlineCellHotkeyScope } from '@/object-record/record-inline-cell/types/InlineCellHotkeyScope';
import { getRecordTitleCellId } from '@/object-record/record-title-cell/utils/getRecordTitleCellId';
+import { TitleInputHotkeyScope } from '@/ui/input/types/TitleInputHotkeyScope';
import { useGoBackToPreviousDropdownFocusId } from '@/ui/layout/dropdown/hooks/useGoBackToPreviousDropdownFocusId';
import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousHotkeyScope';
import { HotkeyScope } from '@/ui/utilities/hotkey/types/HotkeyScope';
@@ -64,7 +64,7 @@ export const useRecordTitleCell = () => {
);
} 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 00000000000..4f265fa3bc1
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/input/types/TitleInputHotkeyScope.ts
@@ -0,0 +1,3 @@
+export enum TitleInputHotkeyScope {
+ TitleInput = 'title-input',
+}