EDU-18464 | New table component to Help Center#477
Conversation
✅ Deploy Preview for leafy-mooncake-7c2e5e ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
julia-rabello
left a comment
There was a problem hiding this comment.
muito bom! deixei alguns comentários com ajustes, mas para mim o caminho é esse mesmo, tá ficando excelente.
um detalhe: você pode adicionar instruções de teste? como os dados ficam no help-center-content e o componente fica aqui, não fica muito claro como testar isso só abrindo o PR. acabei criando um arquivo local manualmente para testar. o ideal seria uma branch de teste no help-center-content com um arquivo json de exemplo e um artigo mdx usando <DataTable>, para testar o fluxo completo sem precisar configurar tudo do zero.
Co-authored-by: Júlia Rabello <77292838+julia-rabello@users.noreply.github.com>
Co-authored-by: Júlia Rabello <77292838+julia-rabello@users.noreply.github.com>
Co-authored-by: Júlia Rabello <77292838+julia-rabello@users.noreply.github.com>
Co-authored-by: Júlia Rabello <77292838+julia-rabello@users.noreply.github.com>
…ield Remove the two-field pattern (key + urlKey) in favor of a single value that is either a plain URL or a markdown link [label](url). - Remove `urlKey` from `DataTableColumn` type - Parse `[label](url)` with regex; fall back to raw URL as label - Values without `http` render as plain text (no broken link)
|
Added a few changes:
|
- Remove currencyKey from DataTableColumn — currency is column-level only - Check isConnected before destroy() to avoid removeChild error on unmount
LOCAL ONLY — delete before merging. Route: /test-datatable. Covers all column types, edge cases, and error states without requiring help-center-content data.
Security:
- Block javascript:/data: URLs in link type via https?:// allowlist
- Validate country code against /^[A-Z]{2}$/ before building flagcdn URL
- Narrow badgeColors type to Record<string, TagColor> to prevent invalid casts
Correctness:
- Fix race condition: construct instance into local var, destroy if cancelled
- Destroy previous instance before early return when cols is empty
- boolean type now returns empty cell for null/missing values
- resolveTagColor validates override against known TagColor values
Performance:
- Hoist DataTables dynamic import to module-level promise (loaded once)
- Cap regionNamesCache at 20 entries to prevent unbounded growth
- Wrap columnsKey in useMemo
Maintainability:
- Use row.id as React key when available, fall back to index
- Remove dead .dt-badge CSS rule
- Remove redundant Array.isArray guard on columns
- Document context empty-object default and constructor type narrowing
…n info row - Replace single Select with MultiSelect component (checkbox dropdown, multi-value regex search) - Add clear filters button when any filter is active - Move last updated date inline with DataTables info row via drawCallback - Mount SearchIcon via createRoot into DataTables search input - Add search placeholder i18n key (en/pt/es) - Add clearFilters i18n key (en/pt/es) - Normalize results per page select styling (custom chevron, no focus error state) - Remove hidden placeholder option from Select component so All is selected by default
- Two-row filter bar: row 1 shows up to 3 filters (2 when >3 exist) + toggle + search + clear; row 2 shows remaining filters when expanded - Search box always visible; all columns always globally searchable - New DateFilter component: drill-down year/month/day picker with clear per level - Country columns support multiselect UI filter with resolved locale names - i18n: added dateClear, dateClearMonth, dateClearDay, moreFilters keys (en/es/pt) - Updated lessFilters to "Show less filters" across all locales - Clear filters always appears next to toggle when any filter is active
…teners - Merge dateYearOptions and dropdownOptions into a single useMemo pass over rows - Pre-compute colIndexMap (Map<col, index>) to replace O(n) cols.indexOf() calls - Scope mousedown listeners in MultiSelect and DateFilter to only attach when open
- Cap MultiSelect and DateFilter containers at 260px with label truncation - Replace text overflow button with compact +/- icon button (28x28) with tooltip - Add moreFiltersIcon style to datatable styles
There was a problem hiding this comment.
⚠️ test file - remove this file before merging
- Country filter: use alpha-2 code as option value and word-boundary regex to prevent substring false matches (e.g. Niger matching Nigeria) - Cleanup effect: capture tableRef.current before returning cleanup fn to avoid reading a nulled ref after unmount - Remove outline:none from filter trigger buttons to restore keyboard focus visibility in MultiSelect and DateFilter
47e7d7b
What is the purpose of this pull request?
Component for rendering data tables in any Help Center documentation, with search, sorting, and pagination capabilities (via DataTables). The idea is to have the column configuration in MDX and the data in an external JSON in help-center-content, referenced by src.
In the .md file, the table will be created using the tag:
The table data in the .JSON file can be formatted as plain rows or by locale:
The DataTable component renders a
on the server and initializes DataTables on the client via dynamic import, without breaking SSR. Column types:text,link,boolean.Data loading at build-time has been added:
serializeWithFallback→getDataTablesDataextracts the src from the tags, retrieves each JSON from the same branch as the documentation, resolves the rows for the current locale, and appends them toserialized.scope.dataTablesData.ArticleRendermakes the data available via context (DataTablesProvider) and registers the component inMarkdownRendererviacustomComponents.The dependencies used were: datatables.net, datatables.net-dt.
How should this be manually tested?
Screenshots or example usage
Types of changes