Skip to content

Conversation

snowystinger
Copy link
Member

@snowystinger snowystinger commented Aug 21, 2025

Closes RSP Component Milestones (view)

Implements our Editable Cell component for Table's. Note, this is called inline editing by Spectrum at the moment, but it does not correlate to aria inline editing.
This essentially works around the issue of textfields in cells or anything else in cells.

Will be adding more tests

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

🧢 Your Project:

@rspbot
Copy link

rspbot commented Aug 21, 2025

@rspbot
Copy link

rspbot commented Aug 21, 2025

@rspbot
Copy link

rspbot commented Aug 25, 2025

@rspbot
Copy link

rspbot commented Aug 25, 2025

@rspbot
Copy link

rspbot commented Aug 25, 2025

@rspbot
Copy link

rspbot commented Aug 25, 2025

@rspbot
Copy link

rspbot commented Aug 25, 2025

@rspbot
Copy link

rspbot commented Aug 27, 2025

@rspbot
Copy link

rspbot commented Aug 27, 2025

let boundaryStartEdge = boundaryDimensions.scroll[AXIS[axis]] + padding;
let boundaryEndEdge = boundarySize + boundaryDimensions.scroll[AXIS[axis]] - padding;
let startEdgeOffset = offset - containerScroll + containerOffsetWithBoundary[axis] - boundaryDimensions[AXIS[axis]];
let startEdgeOffset = offset - containerScroll + containerOffsetWithBoundary[axis];
Copy link
Member Author

Choose a reason for hiding this comment

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

ignore this change for a bit, might be a bug in our positioning code

…plementation to make generic, fix density, individual cell saving state, use touch detection for showing all the time
**/
onAction?: () => void
onAction?: () => void,
focusMode?: 'cell' | 'child'
Copy link
Member Author

Choose a reason for hiding this comment

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

change we'd need to make if we want to support edit mode on some cells vs others

@rspbot
Copy link

rspbot commented Aug 28, 2025

context={TextContext}
value={{
slots: {
[DEFAULT_SLOT]: {styles: label({size})},
Copy link
Member Author

Choose a reason for hiding this comment

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

this is just a missing feature we should really have in S2

@rspbot
Copy link

rspbot commented Sep 1, 2025

@rspbot
Copy link

rspbot commented Sep 19, 2025

@rspbot
Copy link

rspbot commented Sep 19, 2025

@rspbot
Copy link

rspbot commented Sep 19, 2025

@snowystinger snowystinger changed the title wip: table inline editing feat: table "inline" editing Oct 1, 2025
@snowystinger snowystinger marked this pull request as ready for review October 1, 2025 05:28
@rspbot
Copy link

rspbot commented Oct 1, 2025

@rspbot
Copy link

rspbot commented Oct 2, 2025

Copy link
Member

Choose a reason for hiding this comment

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

one thing I noticed when testing is that tabbing through the table will move you to the edit buttons instead of treating the table as a single tab stop like it does for v3 table, not quite sure why. Note that this specifically happens when selection is enabled: https://reactspectrum.blob.core.windows.net/reactspectrum/f8ad4f7b2000787617b3b6097af722ecf8b5679f/storybook-s2/index.html?path=/story/tableview--editable-table&args=selectionMode:multiple

Copy link
Member Author

Choose a reason for hiding this comment

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

hmmm odd, i'll have a look

Copy link
Member Author

Choose a reason for hiding this comment

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

o, i see
lastChild is the last checkbox, which is in a row, we focus it without scrolling, which makes the edit button visible
then we let tab naturally move us to the next element, which is the now visible edit button...

I think i've fixed it by applying excludeFromTabOrder since the collection should handle moving to and from it

Copy link
Member Author

Choose a reason for hiding this comment

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

added tests as well

isPending: isSaving,
isQuiet: !isSaving,
size,
styles: style({
Copy link
Member

Choose a reason for hiding this comment

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

nit: noticed that the edit button's focus ring is visible behind the checkbox:
image

Copy link
Member Author

Choose a reason for hiding this comment

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

probably ok? probably not common that people keyboard focus, then scroll without clicking somewhere

Copy link
Member

Choose a reason for hiding this comment

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

bit unfortunate that the button is sized/the row outlines are made in such a way that the top of the ring sits flush under the top row's border but the bottom of the ring sits on top of the border. Not too bothered by it, we can look into it as a followup

if (!popoverRef.current?.contains(document.activeElement)) {
return false;
}
formRef.current?.requestSubmit();
Copy link
Member

Choose a reason for hiding this comment

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

I might just be forgetting prior examples, but I feel like dismissing a popover via clicking outside shouldn't be a confirm/submit action but instead just a cancel action

Copy link
Member Author

Choose a reason for hiding this comment

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

Design specifically says this should confirm 🤷🏻

@rspbot
Copy link

rspbot commented Oct 2, 2025

@rspbot
Copy link

rspbot commented Oct 3, 2025

@rspbot
Copy link

rspbot commented Oct 3, 2025

@rspbot
Copy link

rspbot commented Oct 3, 2025

@rspbot
Copy link

rspbot commented Oct 3, 2025

## API Changes

@react-spectrum/s2

/@react-spectrum/s2:EditableCell

+EditableCell {
+  align?: 'start' | 'center' | 'end' = 'start'
+  children: ReactNode
+  className?: ClassNameOrFunction<CellRenderProps>
+  colSpan?: number
+  id?: Key
+  isSaving?: boolean
+  onCancel: () => void
+  onSubmit: () => void
+  renderEditing: () => ReactNode
+  showDivider?: boolean
+  style?: StyleOrFunction<CellRenderProps>
+  textValue?: string
+}

Copy link
Member

@LFDanLu LFDanLu left a comment

Choose a reason for hiding this comment

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

overall looks pretty good to me, lets get this in for additional browser testing

isPending: isSaving,
isQuiet: !isSaving,
size,
styles: style({
Copy link
Member

Choose a reason for hiding this comment

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

bit unfortunate that the button is sized/the row outlines are made in such a way that the top of the ring sits flush under the top row's border but the bottom of the ring sits on top of the border. Not too bothered by it, we can look into it as a followup

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

Successfully merging this pull request may close these issues.

3 participants