Skip to content

Commit

Permalink
fix: fix overlapping of confirmation buttons by prompt name when user…
Browse files Browse the repository at this point in the history
… deletes the prompt (#54)
  • Loading branch information
IlyaBondar authored Nov 9, 2023
1 parent 9fc002e commit 9e955a0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
* text=auto eol=lf
*.png filter=lfs diff=lfs merge=lfs -text
4 changes: 2 additions & 2 deletions src/components/Chatbar/components/Conversation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export const ConversationComponent = ({ item: conversation, level }: Props) => {
return (
<div
className={classNames(
'group relative flex h-[30px] items-center rounded border-l-2 pr-0.5 hover:bg-green/15',
'group relative flex h-[30px] items-center rounded border-l-2 pr-3 hover:bg-green/15',
selectedConversationIds.includes(conversation.id)
? 'border-l-green bg-green/15'
: 'border-l-transparent',
Expand Down Expand Up @@ -299,7 +299,7 @@ export const ConversationComponent = ({ item: conversation, level }: Props) => {
<div
className={classNames(
'relative max-h-5 flex-1 truncate break-all text-left',
isDeleting || isRenaming ? 'pr-10' : 'group-hover:pr-7',
isDeleting ? 'mr-12' : 'group-hover:mr-4',
)}
>
{conversation.name}
Expand Down
21 changes: 14 additions & 7 deletions src/components/Promptbar/components/Prompt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const PromptComponent = ({ item: prompt, level }: Props) => {
const selectedPromptId = useAppSelector(
PromptsSelectors.selectSelectedPromptId,
);
const isSelected = selectedPromptId === prompt.id;
const showModal = useAppSelector(PromptsSelectors.selectIsEditModalOpen);

const [isDeleting, setIsDeleting] = useState(false);
Expand Down Expand Up @@ -173,9 +174,7 @@ export const PromptComponent = ({ item: prompt, level }: Props) => {
<div
className={classNames(
'group relative flex h-[30px] shrink-0 cursor-pointer items-center rounded border-l-2 pr-3 transition-colors duration-200 hover:bg-violet/15',
selectedPromptId === prompt.id
? 'border-l-violet bg-violet/15'
: 'border-l-transparent',
isSelected ? 'border-l-violet bg-violet/15' : 'border-l-transparent',
)}
style={{
paddingLeft: (level && `${0.875 + level * 1.5}rem`) || '0.875rem',
Expand All @@ -191,7 +190,15 @@ export const PromptComponent = ({ item: prompt, level }: Props) => {
>
<IconBulb size={18} className="text-gray-500" />

<div className="relative max-h-5 flex-1 truncate break-all pr-4 text-left">
<div
className={classNames(
{
'mr-4 xl:mr-0': !isDeleting && !isRenaming && isSelected,
},
isDeleting ? 'mr-12' : 'group-hover:mr-4',
'relative max-h-5 flex-1 truncate break-all text-left',
)}
>
{prompt.name}
</div>
</button>
Expand Down Expand Up @@ -222,7 +229,7 @@ export const PromptComponent = ({ item: prompt, level }: Props) => {
<div
className={classNames(
'absolute right-3 z-50 flex justify-end xl:invisible xl:group-hover:visible',
selectedPromptId === prompt.id ? 'visible' : 'invisible',
isSelected ? 'visible' : 'invisible',
)}
ref={wrapperRef}
onClick={stopBubbling}
Expand Down Expand Up @@ -253,10 +260,10 @@ export const PromptComponent = ({ item: prompt, level }: Props) => {
)}
</div>

{selectedPromptId === prompt.id && showModal && (
{isSelected && showModal && (
<PromptModal
prompt={prompt}
isOpen={selectedPromptId === prompt.id && showModal}
isOpen
onClose={handleClose}
onUpdatePrompt={handleUpdate}
/>
Expand Down

0 comments on commit 9e955a0

Please sign in to comment.