Skip to content

Commit

Permalink
fix: Fix share dialog saving behavior (#3269)
Browse files Browse the repository at this point in the history
## Description

1. You couldn't type space at the end of the shared link name 
2. When clicking outside it would save the value

## Steps for reproduction

1. click button
3. expect xyz

## Code Review

- [ ] hi @kof, I need you to do
  - conceptual review (architecture, feature-correctness)
  - detailed review (read every line)
  - test it on preview

## Before requesting a review

- [ ] made a self-review
- [ ] added inline comments where things may be not obvious (the "why",
not "what")

## Before merging

- [ ] tested locally and on preview environment (preview dev login:
5de6)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env.example`
and the `builder/env-check.js` if mandatory
  • Loading branch information
kof authored May 1, 2024
1 parent 8b99866 commit ec26bd7
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions apps/builder/app/shared/share-project/share-project.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ const Menu = ({ name, hasProPlan, value, onChange, onDelete }: MenuProps) => {
return;
}

onChange({ ...value, name: customLinkName });
setIsOpen(false);
onChange({ ...value, name: customLinkName.trim() });
};

return (
Expand All @@ -127,20 +126,22 @@ const Menu = ({ name, hasProPlan, value, onChange, onDelete }: MenuProps) => {
width: theme.spacing[24],
}}
sideOffset={0}
onInteractOutside={saveCustomLinkName}
>
<Item>
<Label htmlFor={ids.name}>Name</Label>
<InputField
id={ids.name}
color={customLinkName.length === 0 ? "error" : undefined}
value={customLinkName}
onChange={(event) => setCustomLinkName(event.target.value.trim())}
onChange={(event) => setCustomLinkName(event.target.value)}
onKeyDown={(event) => {
if (event.key === "Enter") {
saveCustomLinkName();
setIsOpen(false);
}
}}
onBlur={() => onChange({ ...value, name: customLinkName })}
onBlur={saveCustomLinkName}
placeholder="Share Project"
name="Name"
autoFocus
Expand Down Expand Up @@ -432,12 +433,7 @@ export const ShareProject = ({
);

return (
<Flex
direction="column"
css={{
width: theme.spacing[33],
}}
>
<Flex direction="column" css={{ width: theme.spacing[33] }}>
<Collapsible.Root open={items.length > 0}>
<Collapsible.Content className={collapsibleStyle()}>
{items}
Expand Down

0 comments on commit ec26bd7

Please sign in to comment.