Skip to content

Commit a781991

Browse files
committed
Compact after resize, expose ActiveTabIndex, fix demo add-tile for active tab
1 parent 09978c3 commit a781991

2 files changed

Lines changed: 15 additions & 12 deletions

File tree

PanoramicData.Blazor.Demo/Pages/PDDashboardPage.razor.cs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -100,28 +100,19 @@ private void OnTabAdded(PDDashboardTab tab)
100100

101101
private void OnTileAddRequested()
102102
{
103-
// Find the active tab via the dashboard's tracked index
104103
if (_dashboard is null)
105104
{
106105
return;
107106
}
108107

109-
var (row, col) = _dashboard.FindNextAvailablePosition();
110-
111-
// Determine which tab is active
112-
var activeTab = _tabs.ElementAtOrDefault(0);
113-
if (_tabs.Count > 0)
114-
{
115-
// Use reflection-free approach: the dashboard places in active tab
116-
// For the demo, just use the first tab (the dashboard handles it)
117-
activeTab = _tabs[0];
118-
}
119-
108+
var activeTab = _tabs.ElementAtOrDefault(_dashboard.ActiveTabIndex);
120109
if (activeTab is null)
121110
{
122111
return;
123112
}
124113

114+
var (row, col) = _dashboard.FindNextAvailablePosition();
115+
125116
var newTile = new PDDashboardTile
126117
{
127118
RowIndex = row,

PanoramicData.Blazor/PDDashboard.razor.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ public partial class PDDashboard : PDComponentBase, IAsyncDisposable
145145
[Parameter]
146146
public EventCallback<int> ActiveTabChanged { get; set; }
147147

148+
/// <summary>
149+
/// Gets the index of the currently active tab.
150+
/// </summary>
151+
public int ActiveTabIndex => _activeTabIndex;
152+
148153
protected override void OnInitialized()
149154
{
150155
base.OnInitialized();
@@ -428,6 +433,13 @@ private async Task OnResizePointerUp(PointerEventArgs e)
428433
var tile = _resizingTile;
429434
_resizingTile = null;
430435

436+
// Compact other tiles around the resized tile
437+
var activeTab = (_activeTabIndex >= 0 && _activeTabIndex < Tabs.Count) ? Tabs[_activeTabIndex] : null;
438+
if (activeTab is not null)
439+
{
440+
CompactTiles(activeTab, tile);
441+
}
442+
431443
if (OnTileResize.HasDelegate)
432444
{
433445
await OnTileResize.InvokeAsync((tile, tile.RowSpanCount, tile.ColumnSpanCount)).ConfigureAwait(true);

0 commit comments

Comments
 (0)