Skip to content

RTL data tables: sorting, scrolling and numbers

Test RTL data grids across sorting, column resizing, pinning, virtual scrolling and number formatting while preserving selection and focus.

By , Founder of Ritla

Guide13 min read

A data grid can display Arabic headers in the right order while its interactions still assume English geometry. Drag a resize handle left and the column shrinks away from the pointer. Scroll toward later fields and the virtualizer renders an empty region. Sort the rows and a selection remains attached to a screen position instead of the selected record.

Those failures need more than an RTL stylesheet. A grid's layout engine, pointer calculations, scroll adapter and state model must agree about direction and identity. Its numeric values must retain their meaning while their display changes.

Consider a resource-review grid used by a localization team. It contains resource keys, English source text, Arabic translations and revision counts. The Arabic interface lays out its fields from the right, but the resource keys remain identifiers, source sentences remain English, and ascending revision counts still run from smaller to larger values down the rows.

Configure the engine as well as the DOM#

Start by identifying which layer owns each behavior. A native table can place its first source column on the right through direction alone. A virtualized grid may calculate every visible column's position in JavaScript, so changing CSS does not update its internal coordinate model.

The native table-order and RTL scroll-coordinate behaviors used here were checked in Chromium 151. Treat the library-specific interactions as tests to perform on the installed grid and its supported browsers.

AG Grid's RTL documentation provides an enableRtl option for its layout calculations. In a headless stack, separate features can need separate configuration: TanStack Table version 8 has columnResizeDirection, and TanStack Virtual has isRtl for horizontal scrolling.

LayerWhat direction must govern
Rendered grid boundaryColumn progression and inherited text direction
Resize controllerSign of pointer movement relative to the resized edge
Pinning adapterMapping from logical start/end to the library's placement API
Horizontal virtualizerScroll offset and visible-column calculations
Popup layerDirection and alignment of filters, menus and editors

Check the documentation for the installed version. Do not paste the direction option from one major release into another and assume an accepted object means the feature used it. Inspect the engine's resulting state and exercise a resize or scroll operation.

Keep semantic HTML direction on the grid boundary even when an engine has its own option. A nested RTL grid inside an LTR application is a useful test: page direction alone cannot establish what every locally configured component should do.

Avoid applying global row-reverse, negative transforms or reversed column arrays on top of an engine already configured for RTL. Those changes can make its rendered positions disagree with its calculations for hit testing, resizing and keyboard navigation.

Preserve resource and field identity#

Use stable identities before testing interactions. These two fictional records give the review grid a concrete fixture:

js
const reviewRows = [  {    resourceId: 'collection.open',    source: 'Open collection',    translation: 'افتح المجموعة',    revisions: 6  },  {    resourceId: 'collection.rename',    source: 'Rename collection',    translation: 'أعد تسمية المجموعة',    revisions: 91  }];

The source fields keep the same identities in both locales. A column's translated heading is not its ID, and a row's visible index is not its ID. Store selection, editing state, saved widths and sort keys against those identities.

For example, this AG Grid configuration fragment derives row identity from the resource key. The host merges it with its column definitions, modules and other application options before creating the grid:

js
function reviewGridOptions(direction) {  return {    enableRtl: direction === 'rtl',    getRowId: ({ data }) => data.resourceId  };}

The caller supplies ltr or rtl. AG Grid's row-ID guidance requires an ID to remain stable for a record and unique across rows. If the same resource can appear in several target locales at once, use a stable composite identity that includes the target locale rather than reusing the key alone.

This is not a complete grid implementation. It isolates the direction and identity contract so the host can retain its existing renderers, accessibility behavior and data source.

Keep sorting independent of horizontal direction#

Ascending revisions puts 6 before 91 in Arabic and English. It does not mean “put the largest value nearest the right edge.” Rows still progress vertically, and sorting their records must not reverse the columns inside each row.

Sort and filter numeric fields using raw values. A renderer's Arabic-Indic digits, grouping separators or translated missing-value text are presentation. Feeding those strings into a generic string comparator changes the operation from numeric ordering into text ordering.

For translated text, choose a collation policy rather than sorting by visual position or reversing Unicode strings. Intl.Collator provides locale-sensitive comparison. Decide whether the resource-key column uses code-oriented ordering while the translation column uses Arabic language ordering. Those columns do not have to share a comparator.

Server-side sorting needs the same contract. Send the stable field ID and ascending/descending direction, and let the server sort the complete result set. Sorting only the loaded page can make each page look correct while the overall dataset remains out of order. Add a stable tie-breaker for equal values so pagination does not repeat or skip records as ties move.

Use the grid's supported sortable-header control and expose the current order through its accessibility model. W3C's sortable table example uses a button in the header and aria-sort on the sorted header. A custom grid should communicate equivalent information through its supported semantics.

Upward and downward sort icons do not require horizontal mirroring. Check that each icon and accessible state match the actual row order. Distinguish an unsorted indicator from a sorted indicator by more than color, and translate any sort or filter menu labels supplied by the framework.

Format numbers at the display boundary#

Choose a numbering system for revision counts and apply it to cell renderers, group summaries, filter summaries and result counts. A grid can otherwise show Arabic-Indic digits in one renderer and Western digits in a built-in footer without any individual formatter appearing broken.

Keep revision counts numeric in the data model. Give the presentation layer an explicit formatter:

js
const reviewCountFormat = new Intl.NumberFormat('ar', {  numberingSystem: 'arab',  maximumFractionDigits: 0}); function formatReviewCount(value) {  return Number.isSafeInteger(value) && value >= 0    ? reviewCountFormat.format(value)    : 'غير متاح';}

The host calls this for a raw revision count. It deliberately distinguishes an unavailable or invalid count from zero. Intl.NumberFormat handles the chosen display; the grid's comparator and numeric filter still receive the underlying number.

An editable numeric filter is another boundary. Formatting a count does not teach an editor how to parse Arabic-Indic input. Test the editor's documented input policy with pasted values, an empty field and grouping punctuation. Do not use a chain of punctuation replacements as a universal locale parser.

English source sentences and resource keys should have local direction treatment without turning the grid LTR. Mark intentional English prose with its language and direction. Isolate identifier tokens where needed, and keep their bytes unchanged. In a translation editor, English source content is intentional; untranslated interface controls are a different issue.

Align numbers according to the product's comparison policy, then verify how local cell direction affects logical alignment. For mixed values and signs, continue with numbers inside RTL text, rather than changing the grid engine's direction to repair one token.

Resize from the edge the user is dragging#

For a column whose start edge stays fixed, its resize handle belongs at inline end. In RTL, that end is on the left. Dragging the end farther left should increase the column's width, not decrease it.

Suppose the column starts at 224px wide. The pointer moves from x-coordinate 510 to 466, a displacement of negative 44px. An LTR calculation adds that displacement and produces 180px. For this RTL end handle, the intended result is 268px.

Problem: the controller always adds physical pointer movement.

js
function ltrOnlyReviewWidth(startWidth, startX, currentX) {  return Math.min(640, Math.max(160, startWidth + currentX - startX));}

Better: for this same end-handle contract, apply the direction sign before clamping.

js
function resizedReviewWidth(startWidth, startX, currentX, direction) {  const movement = currentX - startX;  const inlineMovement = direction === 'rtl' ? -movement : movement;  return Math.min(640, Math.max(160, startWidth + inlineMovement));}

These are geometry helpers, not complete pointer handlers. Inputs are the captured starting width and pointer coordinate, the latest coordinate, and the direction at gesture start. The bounds are example product limits to adjust for the actual field. Resizing from another edge or distributing width across a group needs a different calculation.

Use the library's resize handler when it already implements that contract. For TanStack Table version 8, configure columnResizeDirection: 'rtl' instead of additionally negating the handler's result. Applying both fixes can reverse the correction again.

Move the rendered handle too. A correctly signed calculation attached to the old physical right edge still feels wrong. With a custom header, logical placement can express the intended edge:

css
.review-header { position: relative; }.review-resize-handle {  position: absolute;  inset-inline-end: 0;  inset-block: 0;  inline-size: 0.75rem;  cursor: col-resize;}

The host supplies the handle's events and accessible controls; this CSS only locates its hit area. Keep that area separate from the sort button. Test short drags, min/max limits, pointer cancellation, touch input and double-click auto-sizing if supported. A resize should not accidentally toggle the sort order on release.

Offer a non-drag way to set or reset width, such as a column-menu command or a numeric width input. W3C's Dragging Movements guidance explains why keyboard support alone is not the same as a pointer alternative to dragging.

Translate pinning intent into the library's API#

The review grid keeps resource identity at inline start while the source and translation fields scroll. The application can store that as start, but a library may accept physical left and right values instead.

For an API with physical side names, this adapter maps the stored intent:

js
function reviewPinSide(edge, direction) {  if (edge !== 'start' && edge !== 'end') {    throw new RangeError('Expected a logical pin edge');  }  const startSide = direction === 'rtl' ? 'right' : 'left';  return edge === 'start'    ? startSide    : startSide === 'left' ? 'right' : 'left';}

The host supplies a logical edge and ltr or rtl. AG Grid's column-pinning documentation exposes left/right pinning; other systems may offer a different abstraction. Verify what the API names mean before translating them or assuming RTL remaps them automatically.

Check the entire pinned region, not only the first header. Selection controls, row renderers, group headers and the corresponding header cells must occupy the same region. Several pinned columns need consistent measured widths after resizing and font loading. A body offset calculated from yesterday's width can overlap a neighboring field even when the header looks correct.

Preserve room for the center viewport on phones. If a long resource key consumes the screen, define an unpinning or compact-view policy rather than letting the center width collapse. Restore saved pinning by column ID and logical intent when changing locale, not by whichever side the previous session called left.

Reorder fields through their identities#

If reviewers can move columns, describe a drop as a change to the field model. Moving revision counts after translation should produce that logical relationship in both locales. A physical x-coordinate is only the input used to identify the destination; it is not the saved column identity.

An algorithm that counts headers to the left of the pointer can choose the wrong destination in RTL. Pinned copies and virtualized headers add another problem: not every rendered header is an independent field, and not every available field is rendered. Use the grid's column-move API and inspect the resulting ordered column IDs.

Test dropping before and after the translation field, crossing a pinned-region boundary and moving a grouped header if the feature allows it. Confirm that the header, body renderer, filter state and saved width all travel with the same field. Do not repair a failed drop by reversing the entire column order afterward.

Offer a menu-based move action when drag reordering is available. Name its destination in terms the reviewer can understand, such as moving a field before another named field. After hiding the focused field, move focus to a remaining meaningful header or cell rather than leaving an active-column reference pointing at content that no longer exists.

Normalize native scroll coordinates only once#

In an RTL native scroller whose content extends leftward, scrollLeft is zero at the rightmost start and becomes negative toward later content. A progress calculation that assumes a positive offset can report no movement while the user is scrolling normally. MDN's scrollLeft reference documents this behavior, including fractional offsets and overscroll differences.

For a native CSSOM scroll element, this helper returns distance from inline start, clamped to its scrollable range:

js
function reviewInlineOffset(scroller, direction) {  const maximum = Math.max(0, scroller.scrollWidth - scroller.clientWidth);  const raw = direction === 'rtl'    ? -scroller.scrollLeft    : scroller.scrollLeft;  return Math.min(maximum, Math.max(0, raw));}

The caller supplies the actual scroll element and its computed direction. This is an adapter for native offsets, not an instruction to modify every grid API value. A framework may already expose a normalized distance. Negating that value again can break its visible-column calculation.

Test the start, middle and far end of the center viewport with pinned regions enabled. Those regions reduce the usable area; the document's width is not the width available to scrollable columns. Compare header and body offsets during trackpad movement and while a resize changes the range.

Use the grid's reveal-column or reveal-cell API when available. A virtualized cell may not exist in the DOM yet, so calling a DOM scrolling method on the desired field cannot materialize it. Even for an existing node, scrollIntoView can scroll ancestors; verify that revealing a cell does not unexpectedly move the page.

Keep the outer application within the viewport and bound the grid's scroller to its allocated space. Hiding document overflow can disguise a grid whose minimum width is escaping its parent. Diagnose that layout separately with fixing horizontal overflow in RTL.

Exercise virtualization beyond the first screen#

A virtualizer can render the initial rightmost columns correctly and fail only after the scroll offset becomes negative. Test a field near the far end, then scroll back. Include pinned columns and a resized field, because their geometry changes the visible range.

TanStack Virtual's isRtl option concerns horizontal scrolling. It does not translate headers, choose number formatting or define your pinning policy. Configure the relevant layer rather than treating one flag as a complete Arabic implementation.

Reused row elements must receive the new record's data, selection state and event context. In the review grid, scroll a selected resource out of the rendered window, then back. Sorting afterward must leave the selection attached to that resource, not to the recycled row element.

Arabic translations can wrap differently from English source text. If rows have variable height, remeasure them after a font loads, a translation changes or a column is resized. If the product deliberately uses fixed-height rows, provide a usable way to inspect full text rather than clipping the only copy of the translation.

Expose the total row/column structure and rendered positions through the grid's supported accessibility model. W3C's grid and table properties guidance covers counts and indices when only part of a table is present. Do not number the current rendered window as though it were the complete dataset, or reverse semantic column indices merely to imitate physical x-coordinates.

Keep keyboard editing and row selection coherent#

An interactive grid needs a defined keyboard model. The WAI-ARIA grid pattern distinguishes cell navigation from interaction with controls inside cells. Adding role="grid" to a static table does not implement that behavior.

For spatial left/right navigation in the Arabic layout, verify the destination by field identity: moving left from an earlier field should reach its left-positioned neighbor. Test the installed library's documented RTL behavior. Up/down movement still navigates records; it should not invert because the interface is Arabic.

Once editing English source or Arabic translation, arrow keys may belong to the text editor's caret. Test entering and leaving edit mode, Escape cancellation and committing a value. A page-level RTL key handler can accidentally capture those keys and move focus away while the reviewer is typing.

Selection also needs an explicit scope. Does a header checkbox select the loaded page, all filtered resources, or all resources? Translate its label accordingly and preserve that meaning after a filter change. Bulk actions should consume selected resource IDs, not visual row numbers. Test a filtered-out selected row and a partially selected group.

Preserve accepted state during remote updates#

Sort, filter and pagination requests can complete in a different order from their initiation. A slower response for an old query must not replace newer Arabic results or restore an obsolete sort indicator. Give requests identities and apply results only while they still belong to the current query.

Keep the accepted query, displayed rows, total count and sort state in agreement. If a request fails, retain a coherent previous result or show a clearly identified error state. Do not leave an ascending indicator over rows fetched with the previous descending request.

For cursor pagination, include the query and ordering context in the cursor contract. A locale change can alter translated-text collation even though it does not change numeric ascending order. Reset or migrate the cursor according to the data service's rules instead of reusing it indiscriminately.

Check whether the installed grid permits changing its direction option on an existing instance. If it requires recreation, snapshot semantic state first: resource IDs, field IDs, logical pinning and accepted query. Restore that state through supported APIs instead of copying physical offsets from the old instance.

Translate built-in UI separately from row data. Filter operators, empty states, loading messages, column menus and selection announcements can remain English after every visible header has been translated. AG Grid's localization documentation describes its UI-text layer. Custom popup renderers also need the intended direction when rendered outside the grid's DOM subtree.

Test combinations that change the coordinate model#

Start with the resource-review fixture, then add missing numeric data, equal counts, long Arabic translations and enough rows and columns to activate virtualization. Compare the same records in LTR and RTL rather than comparing unrelated screenshots.

ScenarioEvidence to collect
Resize an end handlePointer, handle, header width and body width agree
Reach the far-end fieldThe virtualizer renders the intended column without a blank region
Pin and resize identity columnsThe center viewport remains usable and row/header boundaries match
Sort while a row is selectedSelection and actions retain the same resource ID
Edit after recycling rowsThe editor and save request belong to the visible resource
Switch numbering systemDisplay changes while numeric order and filter meaning remain stable
Delay an old server responseNewer rows and accepted query state remain intact
Change locale with saved layoutColumn identity, widths and logical pinning survive coherently

Include keyboard, touch and pointer alternatives to resizing and moving columns. Check that a focused cell is visible rather than covered by a pinned region. Repeat at increased text size and after the Arabic font loads; cached dimensions can conceal failures in the initial render.

Visual inspection establishes placement and clipping. Interaction tests establish which resource is edited, which rows a bulk action affects and whether a virtualizer reaches its far end. Neither replaces the other.

A free Ritla scan can check for direction-sensitive physical properties without an RTL override, R030, and Arabic-Indic and Western digits mixed in the same context, R061. For clipped grid content, continue with Arabic text overflow; for layout failures that appear after resizing, see debugging RTL layout problems.

Checks in this guide

See what your Arabic pages are hiding

Paste a URL. Ritla renders the page on desktop and mobile, runs every check, and shows the top issues with screenshot evidence.

Scan a page freeBrowse the checks