Skip to content

EDU-18464 | New table component to Help Center#477

Open
anabaarbosa wants to merge 29 commits into
mainfrom
tablecomponent
Open

EDU-18464 | New table component to Help Center#477
anabaarbosa wants to merge 29 commits into
mainfrom
tablecomponent

Conversation

@anabaarbosa

Copy link
Copy Markdown
Contributor

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:

<DataTable
  src="/data/tables/payment-providers.json"
  columns={[
    { key: "country", label: "País", type: "text", filterable: true },
    { key: "provider", label: "Provedor", type: "link", urlKey: "docsUrl", sortable: true },
    { key: "payoutSplit", label: "Split de pagamentos", type: "boolean", filterable: true }
  ]}
/>

The table data in the .JSON file can be formatted as plain rows or by locale:

{
  "updatedAt": "2026-06-11",
  "rows": [
    { "country": "BR", "provider": "Aarin", "docsUrl": "https://...", "payoutSplit": true }
  ]
}

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: serializeWithFallbackgetDataTablesData extracts 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 to serialized.scope.dataTablesData. ArticleRender makes the data available via context (DataTablesProvider) and registers the component in MarkdownRenderer via customComponents.

The dependencies used were: datatables.net, datatables.net-dt.

How should this be manually tested?

Screenshots or example usage

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Requires change to documentation, which has been updated accordingly.

@anabaarbosa anabaarbosa self-assigned this Jun 19, 2026
@anabaarbosa anabaarbosa added release-no No release bump effort-medium We estimate the effort to solve this issue is medium.. labels Jun 19, 2026
@netlify

netlify Bot commented Jun 19, 2026

Copy link
Copy Markdown

Deploy Preview for leafy-mooncake-7c2e5e ready!

Name Link
🔨 Latest commit 47e7d7b
🔍 Latest deploy log https://app.netlify.com/projects/leafy-mooncake-7c2e5e/deploys/6a457ad79fc1cd000894a72b
😎 Deploy Preview https://deploy-preview-477--leafy-mooncake-7c2e5e.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

github-actions[bot]
github-actions Bot previously approved these changes Jun 19, 2026

@julia-rabello julia-rabello left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/utils/getDataTablesData.ts Outdated
Comment thread src/components/datatable/index.tsx Outdated
Comment thread src/components/datatable/index.tsx
Comment thread src/components/datatable/index.tsx Outdated
Comment thread src/utils/escapeCurlyBraces.ts Outdated
Comment thread src/utils/escapeCurlyBraces.ts Outdated
Comment thread src/components/datatable/datatable.types.ts Outdated
Comment thread src/components/datatable/index.tsx Outdated
Comment thread src/components/datatable/styles.ts
Comment thread src/components/datatable/index.tsx
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>
github-actions[bot]
github-actions Bot previously approved these changes Jun 23, 2026
Co-authored-by: Júlia Rabello <77292838+julia-rabello@users.noreply.github.com>
github-actions[bot]
github-actions Bot previously approved these changes Jun 23, 2026
Co-authored-by: Júlia Rabello <77292838+julia-rabello@users.noreply.github.com>
github-actions[bot]
github-actions Bot previously approved these changes Jun 23, 2026
github-actions[bot]
github-actions Bot previously approved these changes Jun 26, 2026
github-actions[bot]
github-actions Bot previously approved these changes Jun 26, 2026
…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)
github-actions[bot]
github-actions Bot previously approved these changes Jul 1, 2026
@julia-rabello

julia-rabello commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Added a few changes:

  • Test page (delete before merging): /test-datatable
  • Filter UI
  • Flags: replaced flag emoji with flagcdn.com rectangular images, more neutral than those used in payment-providers-table https://flagpedia.net/download/api
  • Badge/tag colors: switched to the Tag component from @vtexdocs/components for consistency with the rest of the dev portal
  • Fixed cell alignment and nowrap
  • Pagination: arrow symbols instead of translated words (« ‹ › »); current page now uses neutral gray instead of pink
  • Unavailable state: added a warning box (yellow, matching the portal's callout style) with i18n strings in EN, PT, and ES when the data source can't be found
  • Link column: simplified from two fields (key + urlKey) to a single value, either a plain URL or label markdown. The urlKey prop has been removed.
  • Remove currencyKey from DataTableColumn, currency is column-level only
  • Solved conflicts and linting issues.

- 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.
github-actions[bot]
github-actions Bot previously approved these changes Jul 1, 2026
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
github-actions[bot]
github-actions Bot previously approved these changes Jul 1, 2026
…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
github-actions[bot]
github-actions Bot previously approved these changes Jul 1, 2026
julia-rabello
julia-rabello previously approved these changes Jul 1, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ 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
@julia-rabello julia-rabello dismissed stale reviews from github-actions[bot] and themself via 47e7d7b July 1, 2026 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort-medium We estimate the effort to solve this issue is medium.. release-no No release bump

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants