Revert "[Permissions] Force open title input for role label when empty" (#12817)
Reverts twentyhq/twenty#12710
This commit is contained in:
@ -6,9 +6,7 @@ import { useRef, useState } from 'react';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
import { useRegisterInputEvents } from '@/object-record/record-field/meta-types/input/hooks/useRegisterInputEvents';
|
||||
import { titleInputComponentState } from '@/ui/input/states/titleInputComponentState';
|
||||
import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousHotkeyScope';
|
||||
import { useRecoilComponentStateV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentStateV2';
|
||||
import styled from '@emotion/styled';
|
||||
import { OverflowingTextWithTooltip } from 'twenty-ui/display';
|
||||
|
||||
@ -27,7 +25,6 @@ type InputProps = {
|
||||
|
||||
export type TitleInputProps = {
|
||||
disabled?: boolean;
|
||||
instanceId: string;
|
||||
} & InputProps;
|
||||
|
||||
const StyledDiv = styled.div<{
|
||||
@ -145,18 +142,14 @@ export const TitleInput = ({
|
||||
onClickOutside,
|
||||
onTab,
|
||||
onShiftTab,
|
||||
instanceId,
|
||||
}: TitleInputProps) => {
|
||||
const [isTitleInputOpen, setIsTitleInputOpen] = useRecoilComponentStateV2(
|
||||
titleInputComponentState,
|
||||
instanceId,
|
||||
);
|
||||
const [isOpened, setIsOpened] = useState(false);
|
||||
|
||||
const { setHotkeyScopeAndMemorizePreviousScope } = usePreviousHotkeyScope();
|
||||
|
||||
return (
|
||||
<>
|
||||
{isTitleInputOpen ? (
|
||||
{isOpened ? (
|
||||
<Input
|
||||
sizeVariant={sizeVariant}
|
||||
value={value}
|
||||
@ -168,7 +161,7 @@ export const TitleInput = ({
|
||||
onClickOutside={onClickOutside}
|
||||
onTab={onTab}
|
||||
onShiftTab={onShiftTab}
|
||||
setIsOpened={setIsTitleInputOpen}
|
||||
setIsOpened={setIsOpened}
|
||||
/>
|
||||
) : (
|
||||
<StyledDiv
|
||||
@ -176,7 +169,7 @@ export const TitleInput = ({
|
||||
disabled={disabled}
|
||||
onClick={() => {
|
||||
if (!disabled) {
|
||||
setIsTitleInputOpen(true);
|
||||
setIsOpened(true);
|
||||
setHotkeyScopeAndMemorizePreviousScope({
|
||||
scope: hotkeyScope,
|
||||
});
|
||||
|
||||
@ -11,7 +11,6 @@ const meta: Meta<typeof TitleInput> = {
|
||||
placeholder: 'Enter title',
|
||||
hotkeyScope: 'titleInput',
|
||||
sizeVariant: 'md',
|
||||
instanceId: 'title-input-story',
|
||||
},
|
||||
argTypes: {
|
||||
hotkeyScope: { control: false },
|
||||
|
||||
@ -1,4 +0,0 @@
|
||||
import { createComponentInstanceContext } from '@/ui/utilities/state/component-state/utils/createComponentInstanceContext';
|
||||
|
||||
export const TitleInputComponentInstanceContext =
|
||||
createComponentInstanceContext();
|
||||
@ -1,17 +0,0 @@
|
||||
import { TitleInputComponentInstanceContext } from '@/ui/input/contexts/titleInputComponentInstanceContext';
|
||||
import { titleInputComponentState } from '@/ui/input/states/titleInputComponentState';
|
||||
import { createComponentSelectorV2 } from '@/ui/utilities/state/component-state/utils/createComponentSelectorV2';
|
||||
|
||||
export const titleInputComponentSelector = createComponentSelectorV2({
|
||||
key: 'titleInputComponentSelector',
|
||||
get:
|
||||
({ instanceId }) =>
|
||||
({ get }) => {
|
||||
const isTitleInputOpen = get(
|
||||
titleInputComponentState.atomFamily({ instanceId }),
|
||||
);
|
||||
|
||||
return isTitleInputOpen;
|
||||
},
|
||||
componentInstanceContext: TitleInputComponentInstanceContext,
|
||||
});
|
||||
@ -1,8 +0,0 @@
|
||||
import { TitleInputComponentInstanceContext } from '@/ui/input/contexts/titleInputComponentInstanceContext';
|
||||
import { createComponentStateV2 } from '@/ui/utilities/state/component-state/utils/createComponentStateV2';
|
||||
|
||||
export const titleInputComponentState = createComponentStateV2<boolean>({
|
||||
key: 'titleInputComponentState',
|
||||
defaultValue: false,
|
||||
componentInstanceContext: TitleInputComponentInstanceContext,
|
||||
});
|
||||
Reference in New Issue
Block a user