Repository navigation
feat(pages): add a tabs widget whose tabs hold their own widgets - #3217
rubenvdlinde wants to merge 17 commits into
Conversation
7e2a1c0 to
2e55f28
Compare
2e55f28 to
1181602
Compare
1181602 to
6472d8c
Compare
6472d8c to
5dda44c
Compare
5dda44c to
dfb367d
Compare
AndyScherzinger
left a comment
There was a problem hiding this comment.
Review focused on performance, accessibility, security, clean code and architecture. The UI checks ran on a dev instance (MariaDB) with the frontend built from this PR, on pages with tabs widgets set up through the API. They covered axe-core 4.14 on a page with a tabs widget (only the four rules of the table grid that main already has, tracked separately), the tabs with the keyboard (arrows, Home, End, Enter work), the heading levels, saving, configuring, adding to a tab, narrow tabs widgets at 1920 px, and tab switches with a table in a tab.
Fixed by this PR, confirmed on the instance: saving an unchanged page keeps the widgets in their tabs (raised on #3213), and "Configure widget" on a tabs widget opens a working dialog (raised on #3214). Removing the last tab moves its widgets into the new last tab, and "Add widget to this tab" doesn't offer the tabs type and returns focus to its button.
Security: nothing found. Tab titles and widget texts are rendered as text, and the server validates the tabs setting again.
Also seen here, from earlier PRs:
- The "Tabs, one per line" field shows the placeholder "Leave an empty line between paragraphs" from
SchemaForm(the risk raised on #3214). - After the "Configure widget" dialog closes, focus is on
<body>: the menu item that opened it no longer exists (reproduced; the dialog is from #3214, the configure flow from #3215). WidgetService::appendDataWidget(#3211) counts the widgets inside tabs when it places a table added later on the start page, which leaves a gap below a tabs widget; counting only widgets with no parent fixes it (code check only).
| role="tabpanel" | ||
| class="tabs-widget__panel" | ||
| :aria-labelledby="tabId(activeTab)"> | ||
| <GridCanvas :key="activeTab" |
There was a problem hiding this comment.
After a tab switch, the re-keyed GridCanvas runs GridStack.init inside an item of the page grid, which already exists. GridStack 13 then sets parentGridNode from the enclosing .grid-stack-item and sends every change event to the outermost grid, so the tab canvas's change handler never fires and the page canvas gets the tab's nodes. In edit mode, a step that pushes a neighbour starts a loop between the page and the tab canvas. Leaving the page afterwards also fails in the tab grid's destroy. The tab shown on the first load isn't affected, because it mounts before the page grid. Detaching the nested grid in GridCanvas.mounted (if (this.grid.parentGridNode) { delete this.grid.parentGridNode.subGrid; delete this.grid.parentGridNode }) avoids it; the component test mounts without a page grid, so it can't catch this.
Validated: reproduced on a deployed instance (MariaDB, 2.4 data upgraded through #3133 to #3212, frontend built from this PR at dfb367d1: tabs widget with "Alpha" above "Beta" in its second tab, switched to that tab, Edit page, "Make taller" on Alpha: the browser tab crashed). Leaving the page: code check only.
There was a problem hiding this comment.
Thanks for tracking this down to parentGridNode. A canvas in a tab now detaches itself from the page grid right after GridStack.init, so it handles its own changes and no longer loops or fails on destroy. The component test can't see a page grid, so the Playwright spec now switches tabs, edits the page and resizes a widget in the tab.
cc @blizzz
| if (widget.key === configuredKey) { | ||
| return { ...widget, title: payload.title, icon: payload.icon, description: payload.description, settings: payload.settings, nodeRelId: payload.nodeRelId } | ||
| } | ||
| if (widget.parentKey === configuredKey && widget.parentTab > lastTab) { |
There was a problem hiding this comment.
Tabs are matched by position, and widgets are only re-bound when the number of tabs shrinks. Removing a line in the middle, inserting one or reordering moves the widgets of every later tab under another title, and the last tab's widgets are merged into the new last tab at their old coordinates, overlapping. No UI moves a widget between tabs, so after Save the only repair is to delete and re-add. The old titles are still in this.widgetBeingConfigured.settings, so remapping by title (and placing moved widgets at nextFreeRow of the target tab) keeps them where they belong.
Validated: reproduced on a deployed instance (MariaDB, 2.4 data upgraded through #3133 to #3212, frontend built from this PR at dfb367d1: tabs "Open / In progress / Done / Empty", "In progress" removed: "Done" then showed the In-progress widgets Alpha, Beta and the table, "Empty" showed Done's widget).
There was a problem hiding this comment.
You're right that positions were the wrong key. Tabs are now a list of a key and a title, and a widget in a tab stores the key of its tab, so renaming, reordering or inserting tabs leaves every widget where it was. Removing a tab moves its widgets onto the page below what is already there, and cancelling the page edit brings them back.
cc @blizzz
| :nodes="actions.nodes()" | ||
| :layout-item="item" | ||
| :editable="editable" | ||
| :arrangeable="!narrow" |
There was a problem hiding this comment.
The tab's canvas applies the page's breakpoints to its own width, so a tabs widget narrower than about 8 of 12 columns gets a 6-column grid even on a wide screen. Its widgets then lose every Move and Make step (the only keyboard way to arrange them), mouse changes are dropped, and the tab shows "Widen the window to arrange the widgets.", which no window size fixes. A nested canvas should follow the page canvas's column mode (provided by the page GridCanvas), with the hint coming from the page.
Validated: reproduced on a deployed instance (MariaDB, 2.4 data upgraded through #3133 to #3212, frontend built from this PR at dfb367d1: 1920 px window, tabs widget 6 columns wide, tab grid 894 px with gs-6, the hint shown, and the menu of the widget in the tab only "Configure widget | Remove widget").
There was a problem hiding this comment.
Agreed. The page canvas now passes its column mode down, so a canvas in a tab arranges whenever the page does and only the page shows the hint. There is a component test for a narrow canvas in a tab.
cc @blizzz
| return 'tabs-widget-panel-' + this.instance | ||
| }, | ||
| layout() { | ||
| return levelLayout(this.actions.grid(), this.widget.key, this.activeTab) |
There was a problem hiding this comment.
Only the open tab's widgets are mounted, so every tab switch destroys one tab and creates the other. Each data widget in the opened tab loads its columns and all rows again behind a spinner, and loses its sort, filter, search and scroll position; a load still running when the tab is left keeps going and writes the store. Mounting a tab on its first visit and keeping visited tabs with v-show (which also gives each tab its own tabpanel), or skipping the reload when the store already has the rows, avoids it.
Validated: reproduced on a deployed instance (MariaDB, 2.4 data upgraded through #3133 to #3212, frontend built from this PR at dfb367d1: a table in the second tab, switching to the first tab and back fetched columns and row/table/1 again).
There was a problem hiding this comment.
Agreed. A tab is mounted the first time it is opened and kept with v-show afterwards, with its own tabpanel, so a data widget in a tab keeps its rows, sort, filter and scroll. The canvas of a tab is no longer re-keyed either.
cc @blizzz
| const saved = await ocsRequest(page.request, user, { | ||
| method: 'PATCH', | ||
| url: `${API}/contexts/${contextId}/pages/${pageId}?format=json`, | ||
| data: { |
There was a problem hiding this comment.
This PATCH sends widgets without version, which the server rejects since the version check in the base stack, so the test fails in its setup. context-grid-pages.spec.ts sends version: 0 for the same call.
Validated: reproduced on a deployed instance (MariaDB, 2.4 data upgraded through #3133 to #3212, frontend built from this PR at dfb367d1: a widgets PATCH without version returned 400 "A save of the widgets of a page names the version of the page it is based on.").
There was a problem hiding this comment.
Fixed in "test(pages): send the version of a new page with its widgets in the tabs spec": the setup now sends version: 0, the same as context-grid-pages.spec.ts.
cc @blizzz
| <template #icon> | ||
| <InformationOutline :size="20" /> | ||
| </template> | ||
| {{ open ? t('tables', 'Hide description') : t('tables', 'Show description') }} |
There was a problem hiding this comment.
The label switches between "Show description" and "Hide description" while aria-expanded changes too, so screen readers announce the state twice ("Hide description, expanded"), and every data widget's button has the same name. The disclosure pattern keeps one label, ideally naming the table or view ("Description of {title}"). While collapsed, aria-controls points to an id that isn't in the page, because the panel uses v-if.
Validated: reproduced on a deployed instance (MariaDB, 2.4 data upgraded through #3133 to #3212, frontend built from this PR at dfb367d1: collapsed aria-expanded=false, aria-controls to a missing element; after Enter "Hide description" with aria-expanded=true).
There was a problem hiding this comment.
Agreed. The button now has one label, "Description of" plus the table or view, and aria-expanded carries the state alone. The panel stays in the page once opened, and aria-controls only points to it while it exists.
cc @blizzz
| }, | ||
| // The tab in the tab order: the one last moved to with the keyboard, else the open one | ||
| focusTab() { | ||
| return this.focusedTab ?? this.activeTab |
There was a problem hiding this comment.
The roving tabindex is copied from ContextPageBar without its guard (ids.includes(this.focusedPageId)), and focusedTab is only reset when activeTab changes. After End on the fourth tab and configuring the widget down to two tabs, no tab has tabindex="0", so the strip drops out of the Tab order; clicking the already open tab doesn't reset it either. Modifier keys aren't ignored, so Alt+Left/Right (Back/Forward) is swallowed while a tab has focus. Taking the start from event.target, resetting focusedTab in the titles watcher and on focusout, and returning early on Alt/Ctrl/Meta, in one helper shared with ContextPageBar, fixes it.
Validated: code check only.
There was a problem hiding this comment.
Thanks, all three were real. The key handling is now one helper shared by ContextPageBar and the tabs widget: it ignores Alt, Ctrl and Meta, starts from the tab the key was pressed on, and one tab always stays in the tab order when the tabs change. Component tests cover End followed by fewer tabs and Alt with an arrow key.
cc @blizzz
| </template> | ||
| {{ open ? t('tables', 'Hide description') : t('tables', 'Show description') }} | ||
| </NcButton> | ||
| <div v-if="open" :id="panelId" class="collapsible-description__panel"> |
There was a problem hiding this comment.
v-if="open" mounts and unmounts TableDescription, whose mounted awaits OCA.Text.createEditor without a guard, while beforeUnmount only destroys an editor that already exists. Hiding the description, or switching the tab, before the first editor resolves leaves a Text editor on a detached element; each later open builds a full editor again. A flag set in TableDescription.beforeUnmount that destroys a late editor fixes every caller; v-if="opened" v-show="open" keeps the panel after the first open.
Validated: code check only.
There was a problem hiding this comment.
Good catch. TableDescription now destroys an editor that resolves after unmount, which helps every place that uses it, and the description panel stays in the page after the first open with v-show. The component test opens and closes it twice.
cc @blizzz
| :editable="editable" | ||
| @layout-change="items => actions.changeLayout(items)"> | ||
| <template #widget="{ item, narrow }"> | ||
| <GridWidget v-if="widgetsByKey[item.widgetId]" |
There was a problem hiding this comment.
This repeats how GridPage renders a level of the grid (GridCanvas + GridWidget with the same eight bindings, lines 77-89 there), and reaches the page through the gridActions bag. widgetsByKey rebuilds the page's widgetsById in every tabs widget on every draft change, and the v-if is always true, because levelLayout only returns items of existing widgets. Any new card action has to be wired in both templates and the bag, or it silently does nothing inside tabs. One GridLevel component (props parentKey and tab) used by GridPage and TabsWidget removes the copy. @layout-change="actions.changeLayout" works without the arrow function.
Validated: code check only.
There was a problem hiding this comment.
Agreed. The page and each tab now render their level through one GridLevel component, with the widget map built once by the page, so a new card action is wired in one place. The always true v-if and the arrow function went with it.
cc @blizzz
| <ElementTitle v-model:view-setting="localViewSetting" :active-element="table" :show-title="showTitle" /> | ||
| <TableDescription :description="table.description" :read-only="true" /> | ||
| <CollapsibleDescription v-if="collapseDescription" :description="table.description ?? ''" /> | ||
| <TableDescription v-else :description="table.description" :read-only="true" /> |
There was a problem hiding this comment.
TableWrapper is only used by DataWidget, which always passes collapse-description, so this branch, the prop and the TableDescription import are dead (View.vue does need its switch). Similar: || widgetType.type === this.editingWidget?.type in AddWidget (line 134) only matters for a tabs widget inside a tab, which the server forbids, and configureWidget sets targetTab only to feed it; TabsWidget's settings prop equals widget.settings; and the module-level id counters in TabsWidget and CollapsibleDescription can be this.widget.key and Vue's useId().
Validated: code check only.
There was a problem hiding this comment.
Thanks, these are cleared out. TableWrapper always collapses now, the editingWidget clause in AddWidget and the targetTab it needed are gone, the tabs widget reads widget.settings directly, and the ids come from the widget key and useId().
cc @blizzz
dfb367d to
5c07fba
Compare
5c07fba to
08501f7
Compare
08501f7 to
6a64d79
Compare
|
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |
1aee275 to
12d9c70
Compare
12d9c70 to
85462eb
Compare
85462eb to
b69e374
Compare
|
This went away with the tab editor that replaces the textarea for tabs. Agreed. When the dialog closes, the focus now goes back to the actions button of the widget that was configured. The change sits lower in the stack, where the configure flow lives, and carries up to this PR. This one is gone with "feat(pages): start a new start page with one tables widget": adding a table no longer places a widget, the tables widget on the start page lists it by itself. cc @blizzz |
A tabs widget puts several grids in the room of one: each tab holds its own widgets, tables and views included. The tab strip follows the tabs pattern for the keyboard, and in edit mode each tab can get widgets of its own, saved with parentIndex and parentTab. A table or view widget shows the description of its table or view behind a button. Co-authored-by: taiebot <13300652+taiebot@users.noreply.github.com> Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
A data widget shows the title of its table in its own heading, the table inside no longer repeats it. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
…abs spec Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
…mponent The page and every tab of a tabs widget rendered their canvas and widgets with their own copy of the same template, and each tabs widget built its own widget map. GridLevel renders one level from what the page provides, with the widget map built once there, so a new widget action is wired in one place. A data widget without a table now hides outside edit mode in a tab as well. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
GridStack takes a grid created inside an item of another grid for its sub grid and sends its changes to the outer grid, which looped between the two in edit mode after a tab switch. The canvas of a tab now detaches from the page grid right after it starts. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
…panel The button switched between "Show description" and "Hide description" while aria-expanded changed too, and every widget's button had the same name. It is called "Description of <title>" now and leaves the state to aria-expanded. The panel stays in the page once opened, so aria-controls only points to it while it exists. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
The canvas of a tab chose its columns from its own width, so a tabs widget narrower than about two thirds of the page showed its widgets reflowed, without the steps to arrange them and with a hint that no window fixes. A nested canvas now arranges whenever the page canvas does and only reflows with it; only the page shows the hint. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
…dget The tabs widget provided the heading level it had when it was created, so widgets in a tab kept it after the tabs widget got or lost a title. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
Each tab switch destroyed the open tab and built the other, so a data widget in a tab loaded its rows again behind a spinner and lost its sorting, filter, search and scroll position. A tab is now mounted when it is first opened and kept with v-show, each with its own tabpanel, so its canvas is also no longer created again on every switch. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
…usable Every tab list was called "Tabs", so two tabs widgets could not be told apart; it takes the title of the widget when it has one. The tab panel scrolls, so it gets tabindex 0 as in the APG tabs example, which lets it scroll with the keyboard in Safari. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
The prompt to name the tabs could not show, since a tabs widget has at least one tab, while an empty tab showed viewers an empty panel. An empty tab now tells viewers it is empty and asks editors to add widgets to it. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
…widget Both tab lists move the focus through one rovingTabTarget() helper, which leaves keys with Alt, Ctrl or Meta to the browser and starts from the tab the key was pressed on. The tabs widget keeps one tab in the tab order when its tabs change and returns to the open tab when the focus leaves it; in both lists a click puts the clicked tab back in the tab order. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
TableWrapper is only used by data widgets, which always collapse the description, so its other branch goes. AddWidget no longer keeps the tabs type for a configured tabs widget in a tab, which the server refuses, nor does configureWidget set the tab it needed. The tabs widget reads its settings from its widget, and the ids come from the widget key and useId() instead of counters at module level. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
…label Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
The server keeps the tabs of a tabs widget as a list of {key, title} and a
widget in a tab names the key of its tab, so the tabs widget, the grid levels
and the save now use that key instead of a position. Renaming, reordering or
inserting a tab keeps every widget in its tab, and the open tab stays open.
A tab that is removed in the widget settings moves its widgets onto the page,
below the widgets already there, each tab's widgets keeping their places
relative to each other. Nothing is deleted without being seen, the move can be
undone by cancelling the page edit, and no second dialog opens inside the
widget dialog.
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
A setting of type `tabs` gets its own editor in the widget settings instead of a textarea with one tab per line: add a tab, rename it, move it up or down and remove it. The editor stops at the `maxItems` of the schema, says how many tabs there are, and marks a title of blanks only by the rule of the server, so no-break, ideographic and zero width spaces count as blank too. Every button is named after its tab, a move or removal is announced in a live region, and the focus stays on a working button or moves to the next tab. A new tab gets a key of twelve hex digits right away, as the server makes them, so widgets can be put in it before the page is saved. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
b69e374 to
ddc3c66
Compare
Part of #3099, on top of #3216 (start page). The UI of the tabs widget from #3212: several grids in the room of one, each tab holding its own widgets, tables and views included. The tab strip and the description button come from #3091 by @taiebot, who is co-author of the commit; here they live in a widget instead of on the start page.
Like #3212, this can be dropped without affecting the others if the model of #3212 isn't wanted.
Size: 680 lines: 466 code and 214 tests.
What changes
parentIndexandparentTabfor the widgets in a tab. Removing a tabs widget removes the widgets in its tabs. The widget dialog doesn't offer Tabs inside a tab.aria-expanded,aria-controls) instead of above the rows, so tables in a widget keep their room.How it was tested
On Nextcloud 34 with PostgreSQL:
context-tabs-widget.spec.ts: tabs with a text and a table, the keyboard, the description button; adding a widget to a tab in edit mode and finding it after a reload.context-grid-pages.spec.tsagain.TabsWidget.cy.js(one grid per tab, keyboard, saving withparentIndex) andCollapsibleDescription.cy.jsnpm run lint,npm run stylelintandnpm run buildKnown gap: dragging a widget inside a tab with the mouse doesn't move it yet; the drag is taken by the grid of the page (GridStack nested in GridStack). Moving and resizing from the widget's menu works inside tabs, and dragging on the page itself works. This needs fixing before this pull request leaves draft.
🖼️ Screenshots
🏁 Checklist
/backport to stableX.X🤖 AI (if applicable)