Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Limit title length to 50 characters in cellUpdate function #212

Merged

Conversation

Aswanth-c
Copy link
Contributor

Fixed #207

I have replaced <h1> to <textarea> because the contentEditable approach in <h1> did not handle text wrapping efficiently, which leads to an overflow of text like below

CleanShot 2024-08-25 at 01 03 28@2x

@Aswanth-c Aswanth-c force-pushed the fix/Cap-title-length-of-srcbooks-#207 branch from e4425b9 to cabde73 Compare August 25, 2024 08:25
Copy link
Contributor

@benjreinhart benjreinhart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this PR!! I have a couple notes:

I know #207 says 50 characters, but we already have one area of validation in the code base for this that uses 44 characters. I prefer 44 for now because that was chosen for a reason previously, though in either case the validation will need to be consistent.

packages/api/server/ws.mts Outdated Show resolved Hide resolved
packages/web/src/components/ui/heading.tsx Outdated Show resolved Hide resolved
@versecafe
Copy link
Collaborator

Why not just allow long names and CSS truncate the text to ... to allow people to easily paste things in without hitting validation issues?

@benjreinhart
Copy link
Contributor

@versecafe we could, and we do this in other places. But given that there's no where in the UI where we render a long title in its entirety, there seems to be no point in allowing one in the first place. IMO, not needing to truncate at all is better than truncating

Copy link
Contributor

@benjreinhart benjreinhart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be easy to reuse the zod schema in all the places where we do validation? If so, can we make that change? That'll make it easier on our future selves when maintaining this.

packages/web/src/components/ui/heading.tsx Outdated Show resolved Hide resolved
packages/web/src/components/ui/heading.tsx Outdated Show resolved Hide resolved
packages/web/src/components/ui/heading.tsx Show resolved Hide resolved
including import existing zod function
Copy link
Contributor

@benjreinhart benjreinhart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allows users to type in a long heading but then it disappears on blur with a clipped version of the text. I think the better UX here would be to prevent them from typing in the long text.

I'm going to merge this for now and can address UX improvement in follow up.

@benjreinhart benjreinhart merged commit 42f66f5 into srcbookdev:main Aug 27, 2024
3 checks passed
@benjreinhart
Copy link
Contributor

Thank you for this 🙏🏻

@Aswanth-c
Copy link
Contributor Author

This allows users to type in a long heading but then it disappears on blur with a clipped version of the text. I think the better UX here would be to prevent them from typing in the long text.

I'm going to merge this for now and can address UX improvement in follow up.

This allows users to type in a long heading but then it disappears on blur with a clipped version of the text. I think the better UX here would be to prevent them from typing in the long text.

I'm going to merge this for now and can address UX improvement in follow up.

The issue where users can type a long heading but it gets clipped on blur is occurring because the latest changes to the TitleCellUpdateAttrsSchema weren’t reflected due to the shared package not being built. In our monorepo setup, the changes only take effect after the package has been properly built.

But I saw you did a great job on ux wise so this doesn't matter

@benjreinhart
Copy link
Contributor

In our monorepo setup, the changes only take effect after the package has been properly built.

Yes I noticed that as well. I thought we had fixed this in #201 but it looks like we still need to build. FWIW you can run pnpm run build in repo root when developing.

@Aswanth-c
Copy link
Contributor Author

In our monorepo setup, the changes only take effect after the package has been properly built.

Yes I noticed that as well. I thought we had fixed this in #201 but it looks like we still need to build. FWIW you can run pnpm run build in repo root when developing.

This branch was behind the turbo branch. I think running turbo dev on a newer versions fix this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cap title length of srcbooks
3 participants