fix(table-core): add header.getIsPinned() for group headers split across pinned regions #6644
Opensundarshahi(GitHub profile, opens in a new tab)wants to merge 4 commits into
main fromrefs/pull/6644/headopened - packages/table-core/src/features/column-pinning/columnPinningFeature.utils.ts line 212Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -191 +191,21 @@191191192+// Header APIs193+194+/**195+ * Reads the pinned region of this header's own leaf columns.196+ *197+ * A group column split across regions renders one header per region, so its198+ * column reports a single position. The header only spans its own leaves:199+ * returns their shared position, or `false` when they are unpinned or mixed.200+ *201+ * @example202+ * ```ts203+ * const position = header_getIsPinned(header)204+ * ```205+ */206+export function header_getIsPinned<207+ TFeatures extends TableFeatures,208+ TData extends RowData,209+ TValue extends CellData = CellData,210+>(header: Header<TFeatures, TData, TValue>): ColumnPinningPosition {211+ const leafHeaders = header.getLeafHeaders()packages/table-core/tests/unit/features/column-pinning/columnPinningFeature.utils.test.ts line 329OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -283,0 +309,21 @@309+310+ it('should report the region each split group header is rendered in', () => {311+ const table = makeSplitGroupTable()312+ const startGroup = table_getStartHeaderGroups(table)[0]!.headers[0]!313+ const centerGroup = table_getCenterHeaderGroups(table)[0]!.headers[0]!314+ const endGroup = table_getEndHeaderGroups(table)[0]!.headers[0]!315+316+ // the shared group column can only report one region317+ expect(column_getIsPinned(endGroup.column)).toBe('start')318+319+ expect(header_getIsPinned(startGroup)).toBe('start')320+ expect(header_getIsPinned(centerGroup)).toBe(false)321+ expect(header_getIsPinned(endGroup)).toBe('end')322+ expect(endGroup.getIsPinned()).toBe('end')323+ })324+325+ it('should return false when a header spans leaves from different regions', () => {326+ const table = makeSplitGroupTable()327+ const groupHeader = table.getHeaderGroups()[0]!.headers[0]!328+329+ expect(groupHeader.getLeafHeaders()).toHaveLength(3)
- docs/framework/ember/guide/column-pinning.md line 142Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -139,3 +139,4 @@139139 `column.getCanPin`: Use to determine if a column can be pinned.140140 `column.pin`: Use to pin a column to the start or end. Or use to unpin a column.141141 `column.getIsPinned`: Use to determine where a column is pinned.142+`header.getIsPinned`: Use to determine where a header is pinned. A group header split across pinned regions reports the region it is rendered in, which `header.column.getIsPinned` cannot.
sundarshahi(GitHub profile, opens in a new tab) linked this to fix #4906
Sign in to join this conversation.
🦋 Changeset detected#
Latest commit: b8b7a8d76c49b978983ac20b62907893a67a4fb1
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 12 packages
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR