Skip to content

fix(mwpw-177207): adds visible Sort by: label to sort dropdown#451

Open
cmiqueo wants to merge 1 commit into
mainfrom
MWPW-177207
Open

fix(mwpw-177207): adds visible Sort by: label to sort dropdown#451
cmiqueo wants to merge 1 commit into
mainfrom
MWPW-177207

Conversation

@cmiqueo
Copy link
Copy Markdown
Collaborator

@cmiqueo cmiqueo commented Apr 30, 2026

Description:
Adds a visible text label before the sort dropdown button in the Consonant top-filter panel, replacing the implicit-only aria-label with an explicit paired element.

L10n:
It can be localized by using the following new key in the mappings file 
sortBy: "Sort by:"

Resolves:
https://jira.corp.adobe.com/browse/MWPW-177207

Before:
Screenshot 2026-04-30 at 8 41 40 AM

After:
Screenshot 2026-04-30 at 8 41 12 AM

Copy link
Copy Markdown
Collaborator

@raissanjay raissanjay left a comment

Choose a reason for hiding this comment

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

Tested locally

  • Built the PR branch (NODE_ENV=production npx webpack) — emitted dist/main.js (890 KB) and dist/app.css (227 KB), no warnings
  • Confirmed bundle contains the new strings: consonant-Select-label, sort-by-Select, Sort by:
  • Served the built dist via WebStorm's built-in server (localhost:63342/caas/), compared before/after on the same test page
  • DOM checks on the rendered after state:
    • [data-testid="consonant-Select-label"] element renders
    • Label text content = "Sort by:"
    • Label htmlFor = "consonant-Select-btn"
    • Button id = "consonant-Select-btn" (matches htmlFor)
    • Label has no aria-label attribute
    • Wrapper carries both consonant-Select and sort-by-Select classes
    • Wrapper computed display: flex, label computed font-size: 13px
    • Gap between label end and button start measured at 0 px (baseline alignment works)
  • Dropdown still functional: click opens popup with all 6 sort options (Random, Featured, Title A-Z, Title Z-A, Date Oldest, Date Newest), aria-expanded toggles to "true"
  • New test file syntax-parses without errors (node --check)
  • Top-filter panel layout (filterPanel.type: 'top'): switched test page config, verified the layout reflows correctly. .consonant-TopFilters renders, sort widget sits at far right per the new justify-content: flex-end (replacing space-between), wrapper sized to fit just label + button (137 px width), no orphan whitespace. The CSS changes inside @media @consonant-desktop-up apply cleanly.
  • Narrow viewport (375 px): constrained body to 375 px via injected style and reloaded — Sort by: label and button remain adjacent on a single line with baseline alignment intact, no wrap or overlap. (Note: the panel.less width-removal changes are inside @media @consonant-desktop-up — the select.less .sort-by-Select rule applies at all widths.)
  • i18n override path: injected i18n: { sortBy: 'Trier par : (custom)' } into the test page's collection config; label rendered the custom string verbatim. Confirms getConfig('collection', 'i18n.sortBy') reads through the override correctly. Authors can swap the label text without touching React code.
  • RTL layout (<html dir="rtl" lang="ar">): the whole page mirrors as expected — filter panel moves to the right, cards reorder, and the sort widget moves to the visual top-left (mirror of LTR top-right). Inside the widget, display: flex flips the label/button visual order so Sort by: appears on the visual right and the dropdown on the visual left, reading naturally in RTL order. Colon position is correctly handled by the Unicode bidi algorithm for English text in an RTL context (would render properly in actual Arabic).

Approving. Verified items look clean across desktop, top-filter layout, narrow viewport, i18n override, and RTL. The only thing I'd nudge before merge is the dead commented-out line in panel.less (inline comment above).

& > div:first-child > button {
padding-left: 12px;
padding-right: 12px;
// padding-left: 12px;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Worth deleting outright rather than leaving it comented out. Lints will skip it but the next person edting this rule will wonder whether 12px was meant tocome back. If the intent is to preserve the originalvalue for reference, a one-line comment above explaiing why (e.g. "intentionally no left padding, label its to the left") would carry more signal than the lteral old line.

const sortPopLabel = screen.getByTestId('consonant-Select-label');

expect(sortPopLabel).toHaveTextContent('Sort by:');
expect(sortPopLabel).not.toHaveAttribute('aria-label');
Copy link
Copy Markdown
Collaborator

@raissanjay raissanjay May 13, 2026

Choose a reason for hiding this comment

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

The not.toHaveAttribute('aria-label') assertion is the right anti-regression check. Without it, a future patch could easily reintroduce an aria-label thinking it adds value, and screen readers would then announce the same control twice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants