Skip to content

Add pin column to all tables via shared PinButton#694

Open
akash-belide wants to merge 1 commit into
masterfrom
pin-table
Open

Add pin column to all tables via shared PinButton#694
akash-belide wants to merge 1 commit into
masterfrom
pin-table

Conversation

@akash-belide

Copy link
Copy Markdown
Contributor

Fixes #661

Summary: Add a far-left pin column to all tables so users can pin rows via the existing pinned page param, using the same CSS-driven PinButton interactions as cards.

Changes
User experience

  • Every table gets a far-left pin column.
  • Pin button appears on row hover; stays visible when the row is already pinned (blue icon).
  • Hovering a pinned button swaps PinIcon → PinOffIcon to signal unpin.
  • Tooltips: "Pin to the page" / "Unpin from the page".
  • Pin column is the sticky left column on horizontal scroll.

Logical changes

  • TablePinCell toggles entity IDs in the pinned page param on click.
  • useColumnVisibility prepends PinColumn to visibleColumns for every table, independent of column visibility settings.

Refactors

  • Extracted shared PinButton (src/shared/ui/PinButton.tsx + pinButton.css) for reuse by cards and tables.
  • Added row-hover visibility rules in tableStyles.css
  • Updated InteractiveEntityTable tests for +1 always-present column header.

Screenshots

image image

@akash-belide akash-belide requested a review from a team as a code owner June 27, 2026 13:55
@github-actions

Copy link
Copy Markdown
Contributor

Cloudflare Pages preview

@conradarcturus conradarcturus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This looks fantastic :D

I realized there are a few interaction problems but I'll mark this approved now because you have a good idea about what you are doing so you can make the update and land the new code without waiting for another approval.


const CardPinButton: React.FC<Props> = ({ isPinned, onTogglePin }) => {
// The action on a pinned card is always to unpin it, so the label reflects that.
const PinButton: React.FC<Props> = ({ className, isPinned, onTogglePin }) => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

great idea to generalize the pin button :)

tbody tr:hover .PinButton,
tbody tr .PinButton.pinned {
visibility: visible;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

btw BaseEntityTable has styling for the first column that makes the ID column sticky so if you see lots of columns and scroll to the right the ID column stays. However that rule is for idx === 0 but now that is the Pin column. Can you update it so its idx <= 1?

While you are there, you can also fix a fun. When I added it, I did not think about conflicting styles so the background row highlight doesn't work for this column. So I would do something similar to before when we add a new value (eg. alwaysVisible) to className if idx <= 1 and do the backgroundColor and etc in this css file.

@@ -35,7 +36,10 @@ function useColumnVisibility<T extends ObjectData>(
);

const visibleColumns = useMemo(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

perfect

key: 'Pin',
label: '',
render: (object) => <TablePinCell object={object} />,
exportValue: () => '',

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ah! I realize since it is always visible, it will be part of the table export. You should update TableExport to omit the "Pin" column when pinned is empty.

.CardPinButton {
/* Position the shared pin button in the card's top-right corner. The button's
own appearance (colors, icon swap) lives in pinButton.css. */
.CardInCardList .PinButton {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

great!

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.

Pins: Add to Table UI

2 participants