feature(splitter): Added support for collapsed panes state - #2299
Open
rkaraivanov wants to merge 2 commits into
Open
feature(splitter): Added support for collapsed panes state#2299rkaraivanov wants to merge 2 commits into
rkaraivanov wants to merge 2 commits into
Conversation
Added support for collapsed panes state in the splitter component. This enhancement allows developers to programmatically control the collapsed state of panes, enabling more dynamic and interactive layouts. The feature includes methods to collapse and expand panes, as well as events to listen for state changes. Closes #2297
Contributor
There was a problem hiding this comment.
Pull request overview
Adds public API support for controlling and observing collapsed/expanded pane state in igc-splitter, aligning the component with the requested “persist/restore layout” scenarios.
Changes:
- Introduces
startCollapsed/endCollapsedproperties (reflected as attributes) to programmatically control pane collapsed state. - Adds
igcExpansionChangedevent and corresponding event args types/exports. - Updates Storybook stories, tests, and changelog to document and validate the new behavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| stories/splitter.stories.ts | Adds Storybook controls + a persisted-layout example using the new properties/event. |
| src/index.ts | Re-exports the new IgcSplitterExpansionChangedEventArgs type from the public entry. |
| src/components/splitter/types.ts | Adds the igcExpansionChanged event typing to the splitter event map. |
| src/components/splitter/splitter.ts | Implements collapsed-state properties and emits igcExpansionChanged for user interactions. |
| src/components/splitter/splitter.spec.ts | Adds unit tests for collapsed-state properties, attribute reflection, and the new event behavior. |
| CHANGELOG.md | Documents the new splitter collapsed-state API and event in the changelog. |
Comments suppressed due to low confidence (2)
src/components/splitter/splitter.ts:513
startCollapsed/endCollapsedare declared withreflect: true, but when collapsed state changes viatoggle()/_handleExpanderAction()(i.e. by updating_collapsedPane), Lit will only consider_collapsedPanechanged and will not re-reflect thestart-collapsed/end-collapsedattributes. This can leave attributes stale (e.g. switching collapsed pane from start->end can keepstart-collapsedpresent). Consider explicitly requesting updates for both public properties when_collapsedPanechanges so attribute reflection stays consistent.
this._collapsedPane = target;
this._internals.setState('start-collapsed', this._isCollapsed('start'));
this._internals.setState('end-collapsed', this._isCollapsed('end'));
src/components/splitter/splitter.ts:170
- Same as the other
@query()fields above: consider re-enabling cached queries to avoid repeated DOM lookups during interaction (consistent with other components, e.g.src/components/button/button-base.ts:54).
@query('[part~="end-pane"]')
private readonly _endPane!: HTMLElement;
Comment on lines
+377
to
+380
| const saved = localStorage.getItem(PERSISTED_LAYOUT_KEY); | ||
| const startCollapsed = saved ? JSON.parse(saved).startCollapsed : false; | ||
| const endCollapsed = saved ? JSON.parse(saved).endCollapsed : false; | ||
|
|
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (2)
src/components/splitter/splitter.ts:163
@query('[part~="base"]')is no longer cached, which is inconsistent with other components that query a stablebasepart (e.g.src/components/tile-manager/tile.ts:189uses@query('[part~="base"]', true)). Since<div part="base">is always rendered here, caching avoids repeated DOM queries on each access and matches established pattern.
@query('[part~="base"]')
stories/splitter.stories.ts:379
- This demo reads persisted state with
JSON.parse(saved)twice and will throw if the stored value is not valid JSON (or iflocalStorageis blocked). Parsing once and guarding errors makes the story more robust.
const saved = localStorage.getItem(PERSISTED_LAYOUT_KEY);
const startCollapsed = saved ? JSON.parse(saved).startCollapsed : false;
const endCollapsed = saved ? JSON.parse(saved).endCollapsed : false;
Comment on lines
+403
to
+404
| @igcExpansionChanged=${(e: CustomEvent) => | ||
| persist(e.target as IgcSplitterComponent)} |
Comment on lines
493
to
+498
| /** Toggles the collapsed state of the specified pane. */ | ||
| public toggle(position: PanePosition): void { | ||
| if (this._collapsedPane === null) { | ||
| // If the requested pane is already collapsed, expand it (set to null) | ||
| // Otherwise, collapse the requested pane (this also handles switching from one collapsed pane to another) | ||
| this._applyCollapse(this._collapsedPane === position ? null : position); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Added support for collapsed panes state in the splitter component. This enhancement allows developers to programmatically control the collapsed state of panes, enabling more dynamic and interactive layouts.
The feature includes methods to collapse and expand panes, as well as events to listen for state changes.
Type of Change
Related Issues
Closes #2297
Checklist