Skip to content

Fix sticky column logic and ColumnDefinition type#267

Merged
edouardmisset merged 6 commits into
masterfrom
em/dra-5002
May 6, 2026
Merged

Fix sticky column logic and ColumnDefinition type#267
edouardmisset merged 6 commits into
masterfrom
em/dra-5002

Conversation

@edouardmisset
Copy link
Copy Markdown
Contributor

@edouardmisset edouardmisset commented May 5, 2026

What does this PR do?

Fixes sticky column class computation in HyperTable v2 and aligns ColumnDefinition.position typing with actual sticky behavior/side usage.

Related to : #DRA-5002

What are the observable changes?

  • Sticky column class is now computed in component logic preventing invalid class generation when position data is missing.

  • Sticky side handling now supports both left and right (hypertable__column--sticky-left / hypertable__column--sticky-right), defaulting to left when sticky is enabled without an explicit side. ⚠️ I took the assumption that the default sticky side is the left side (which seems to be the default behavior in the app) so as to not break the upfluence-web.

  • ColumnDefinition.position now uses a discriminated union:

    • { sticky: false }
    • { sticky: true; side?: 'left' | 'right' }
      This improves type safety and matches runtime behavior.

🧑‍💻 Developer Heads Up

  • The API should not change. The behavior should not change

Good PR checklist

  • Title makes sense
  • Is against the correct branch
  • Only addresses one issue
  • Properly assigned
  • Added/updated tests
  • Added/updated documentation
  • Migrated touched components to Glimmer Components
  • Properly labeled

Additional Notes

Co-authored-by: Copilot <copilot@github.com>
@edouardmisset edouardmisset requested review from a team and phndiaye as code owners May 5, 2026 17:35
@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 5, 2026

@edouardmisset edouardmisset requested review from OwenCoogan and olxmpe and removed request for a team May 5, 2026 17:35
@edouardmisset edouardmisset self-assigned this May 5, 2026
@edouardmisset edouardmisset changed the title fix: sticky column class logic and ColumnDefinition type Fix sticky column logic and ColumnDefinition type May 5, 2026
@edouardmisset edouardmisset marked this pull request as draft May 5, 2026 17:44
Co-authored-by: Copilot <copilot@github.com>
@edouardmisset edouardmisset marked this pull request as ready for review May 5, 2026 18:20
Comment on lines +24 to +30
| {
sticky: false;
}
| {
sticky: true;
side?: 'left' | 'right';
};
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

since the side attribute is optional, what's the difference between what's written and something like

position?: { sticky: boolean; side?: 'left | right' }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's a good question.
The difference is tiny to be honest.
With your implementation, one could write with no problem/warning:
position: { sticky: false; side: 'left' }
IMHO, this could (maybe) trip up a dev.
But with my implementation, if you write this, you get a TS error message saying something like:

"Property side does not exist on type:"

position:
     {
       sticky: false;
     }

IMHO the intent is clearer.
At runtime the code behaves the same.
It only improves the DX.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

FYI: I very briefly talked about it with Phil who told me this syntax was ok for him

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Because there's a world where a dev would write sticky false and also specify a side ?
I disagree - but since you've already merged the PR, whatever I guess.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Do you want me to open another PR to make the change to what you proposed?

}

module('sticky column class', function () {
test('no sticky - column renders without sticky class', async function (this: TestContext, assert: Assert) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: label wording is bit weird - are we talking about the attribute or the feature ?
maybe Sticky attribute not provided - column renders without sticky class is more adapted

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

labels for the two tests below can be updated too

assert.dom('.hypertable__column--sticky-left').exists();
});

test('Sticky attribute provided with right side - column renders with sticky-right class', async function (this: TestContext, assert: Assert) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not sure that's really necessary since you already have a test for the default behavior,
but maybe you could also include a test that checks that passing "left" renders with the sticky-left class?
So you cover default + left side + right side :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If I understood correctly: I implemented an extra test for the defined left side sticky column.
So now we have:

  • no stickiness
  • sticky + default
  • sticky + right
  • sticky + left

@edouardmisset edouardmisset merged commit 51ac38b into master May 6, 2026
3 checks passed
@edouardmisset edouardmisset deleted the em/dra-5002 branch May 6, 2026 13:39
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.

8 participants