@nxgt/material 2.7.0 → 2.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/docs/troubleshooting.md +61 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @nxgt/material
|
|
2
2
|
|
|
3
|
+
## 2.7.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#433](https://github.com/softistx/nxgt-material/pull/433) [`620527a`](https://github.com/softistx/nxgt-material/commit/620527a02ac7f8136e271bc51c32dd28a6d99a25) Thanks [@SteveGT96](https://github.com/SteveGT96)! - Troubleshooting entries for the DataTable server mode: a link or button in the first column of a `getRowHref` table, a row that does not navigate after `onRowClick` / `@row-click`, a disabled Previous or Next, and (Vue) a `:sorting` or `:row-selection` bound without its `update:` half.
|
|
8
|
+
|
|
3
9
|
## 2.7.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/docs/troubleshooting.md
CHANGED
|
@@ -115,6 +115,9 @@ words in your error.
|
|
|
115
115
|
- [Keys typed right after opening a dialog, sheet or drawer land inside it](#keys-typed-right-after-opening-a-dialog-sheet-or-drawer-land-inside-it)
|
|
116
116
|
- [A `TimePicker` test expects AM / PM to add 12 hours, or a click on the pressed half to switch to PM](#a-timepicker-test-expects-am--pm-to-add-12-hours-or-a-click-on-the-pressed-half-to-switch-to-pm)
|
|
117
117
|
- [Focus is no longer in a `Tree` after it renders](#focus-is-no-longer-in-a-tree-after-it-renders)
|
|
118
|
+
- [A link or button in the first column of a `DataTable` with `getRowHref`](#a-link-or-button-in-the-first-column-of-a-datatable-with-getrowhref)
|
|
119
|
+
- [A row does not navigate after `onRowClick` ran](#a-row-does-not-navigate-after-onrowclick-ran)
|
|
120
|
+
- [A `DataTable` Previous or Next button is disabled](#a-datatable-previous-or-next-button-is-disabled)
|
|
118
121
|
|
|
119
122
|
**PDF reader**
|
|
120
123
|
|
|
@@ -2140,6 +2143,64 @@ await userEvent.click(canvas.getByRole('treeitem', { name: /Docs/ }));
|
|
|
2140
2143
|
await userEvent.keyboard('{ArrowDown}');
|
|
2141
2144
|
```
|
|
2142
2145
|
|
|
2146
|
+
### A link or button in the first column of a `DataTable` with `getRowHref`
|
|
2147
|
+
|
|
2148
|
+
**When:** a `DataTable` has `getRowHref`, and the cell of its first data column (the first visible column with an accessor; without one, the first that is not `select` or `expand`) renders a link or a button of its own.
|
|
2149
|
+
**Why:** with `getRowHref` that cell's content is wrapped in the row's link, so a link or button inside it is interactive content nested in a link: React warns of a nested anchor (`<a> cannot be a descendant of <a>`) and the markup may not hydrate, and a click or Enter lands on the inner control or the outer link depending on the target. The row's click handling skips clicks on any control, so the row does not follow its link from there either.
|
|
2150
|
+
**Fix:** keep that column plain, and put the control in another column:
|
|
2151
|
+
|
|
2152
|
+
```tsx
|
|
2153
|
+
const columns = [
|
|
2154
|
+
// the first accessor column renders plain content
|
|
2155
|
+
columnHelper.accessor('name', { header: 'Name' }),
|
|
2156
|
+
// the control goes in a column of its own, after it
|
|
2157
|
+
columnHelper.display({
|
|
2158
|
+
id: 'open',
|
|
2159
|
+
cell: ({ row }) => <Button onClick={() => openSheet(row.original)}>Quick view</Button>,
|
|
2160
|
+
}),
|
|
2161
|
+
];
|
|
2162
|
+
|
|
2163
|
+
<DataTable manual data={rows} columns={columns} getRowHref={(row) => `/students/${row.id}`} linkComponent={RouterLink} />;
|
|
2164
|
+
```
|
|
2165
|
+
|
|
2166
|
+
Anything else that must not make the row follow its link on a click (a custom widget that is not a button, link or field) can carry `data-row-click-ignore`.
|
|
2167
|
+
|
|
2168
|
+
### A row does not navigate after `onRowClick` ran
|
|
2169
|
+
|
|
2170
|
+
**When:** a `DataTable` has both `getRowHref` and `onRowClick`; the handler runs, and a mouse click does not go to the row's page.
|
|
2171
|
+
**Why:** the handler runs first, and the row follows its link only if the click's `defaultPrevented` is still false after it. A handler that calls `event.preventDefault()` therefore stops the navigation by design, which is how a handler cancels it (for a row that opens a sheet instead). Ctrl/Cmd+click on the link, and Enter on it, do not go through the row handler.
|
|
2172
|
+
**Fix:** do not call `preventDefault()` in the handler when the row should still navigate:
|
|
2173
|
+
|
|
2174
|
+
```tsx
|
|
2175
|
+
<DataTable
|
|
2176
|
+
manual
|
|
2177
|
+
data={rows}
|
|
2178
|
+
columns={columns}
|
|
2179
|
+
getRowHref={(row) => `/students/${row.id}`}
|
|
2180
|
+
onRowClick={(row, event) => {
|
|
2181
|
+
openSheet(row); // no event.preventDefault(): the link is still followed
|
|
2182
|
+
}}
|
|
2183
|
+
/>
|
|
2184
|
+
```
|
|
2185
|
+
|
|
2186
|
+
### A `DataTable` Previous or Next button is disabled
|
|
2187
|
+
|
|
2188
|
+
**When:** a server-mode `DataTable` (`manual`) renders its footer with Previous or Next greyed out, though the server has more pages.
|
|
2189
|
+
**Why:** each button is enabled only when `pagination.previous` / `pagination.next` is an href string or a function, and the table is not `loading`. An absent or `null` value gives a disabled button, and both buttons are disabled while `loading` is true, so a `loading` that stays on (a flag never reset after the navigation ended) leaves them disabled. A `pagination` that is not passed renders no buttons at all.
|
|
2190
|
+
**Fix:** pass a target on each side that has a page, and turn `loading` off when the page has arrived:
|
|
2191
|
+
|
|
2192
|
+
```tsx
|
|
2193
|
+
<DataTable
|
|
2194
|
+
manual
|
|
2195
|
+
data={rows}
|
|
2196
|
+
columns={columns}
|
|
2197
|
+
loading={navigation.state === 'loading'}
|
|
2198
|
+
pagination={{ previous: hasPrevious ? previousHref : null, next: hasNext ? nextHref : null, totalCount, offset }}
|
|
2199
|
+
/>
|
|
2200
|
+
```
|
|
2201
|
+
|
|
2202
|
+
---
|
|
2203
|
+
|
|
2143
2204
|
---
|
|
2144
2205
|
|
|
2145
2206
|
## PDF reader
|