Skip to content

Conversation

@Wattenberger
Copy link

image

This adds the option to make the grid editable, similar to a spreadsheet.

Copy link
Contributor

@mattrothenberg mattrothenberg left a 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

value={editedValue}
onChange={e => setEditedValue(e.target.value)}
onKeyDown={e => {
if (e.key === 'Enter') {
Copy link
Contributor

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.

Copy link
Author

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

css={[
tw`h-full w-full max-w-full flex items-center cursor-cell`,
]}
onClick={() => setIsEditing(true)}
Copy link
Contributor

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).

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" }}
Copy link
Contributor

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

Copy link
Author

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

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`,
Copy link
Contributor

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?

tw="relative border-b border-gray-200 bg-white flex items-center flex-shrink-0"
style={{ height: 37 }}
// ref={popoverAnchorRef}
// ref={popoverAnchorRef}
Copy link
Contributor

Choose a reason for hiding this comment

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

lets' remove

@Wattenberger
Copy link
Author

wonderful, thanks for the feedback @mattrothenberg!

@mattrothenberg
Copy link
Contributor

🚢 :shipit:

@Wattenberger Wattenberger merged commit 543f311 into main Jan 19, 2022
@Wattenberger Wattenberger deleted the aw/edit branch January 19, 2022 21:10
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.

3 participants