-
Notifications
You must be signed in to change notification settings - Fork 25
Add editing #16
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
Add editing #16
Conversation
mattrothenberg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some open questions and a11y nitpicks but this looks solid!
Did you consider using an OSS component for the editable input pattern like the Chakra one below? Curious if you found anything cool
src/components/editable-cell.tsx
Outdated
| value={editedValue} | ||
| onChange={e => setEditedValue(e.target.value)} | ||
| onKeyDown={e => { | ||
| if (e.key === 'Enter') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Did you try wrapping this input in form tag? We'd get this enter key functionality for free.
I noticed that https://chakra-ui.com/docs/form/editable does this the same way sans form tag but I'm curious.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
absolutely, good call! I shied away from it to cut down on DOM elements, but in retrospect it's only rendered for actively edited cells so that's silly
src/components/editable-header.tsx
Outdated
| css={[ | ||
| tw`h-full w-full max-w-full flex items-center cursor-cell`, | ||
| ]} | ||
| onClick={() => setIsEditing(true)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make this a button instead of a div (or add the aria attributes that provide the correct hinting that this is interactive).
src/components/editable-header.tsx
Outdated
| css={[ | ||
| tw`w-full h-full py-2 px-2 font-mono text-black text-sm focus:outline-none bg-transparent bg-white`, | ||
| ]} | ||
| style={{ fontSize: "0.875rem" }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this inline style necessary? You have text-sm above too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it was being overridden by a style in the stylesheet - I'll rejigger that, good call
src/components/editable-header.tsx
Outdated
| e.target.select(); | ||
| }} | ||
| css={[ | ||
| tw`w-full h-full py-2 px-2 font-mono text-black text-sm focus:outline-none bg-transparent bg-white`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bg-transparent and bg-white?
src/components/header.tsx
Outdated
| tw="relative border-b border-gray-200 bg-white flex items-center flex-shrink-0" | ||
| style={{ height: 37 }} | ||
| // ref={popoverAnchorRef} | ||
| // ref={popoverAnchorRef} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets' remove
|
wonderful, thanks for the feedback @mattrothenberg! |
|
🚢 |
This adds the option to make the grid editable, similar to a spreadsheet.