Skip to content

Fix Studio toast close-button positioning - #7142

Merged
shimmyshimmer merged 5 commits into
mainfrom
agent/fix-studio-toast-positioning
Jul 15, 2026
Merged

shimmyshimmer merged 5 commits into
mainfrom
agent/fix-studio-toast-positioning

Conversation

@shimmyshimmer

@shimmyshimmer shimmyshimmer commented Jul 15, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Stop locale changes from setting the global document direction.
  • Remove unused locale direction metadata while preserving all language catalogs, detection, persistence, selection, and synchronization behavior.
  • Pin the toast close button to the right edge even if another caller sets a document direction.
  • Limit the language dropdown to 18rem so additional options require scrolling instead of extending down the page.
  • Add regression coverage for locale direction and toast positioning contracts.

Root cause

PR #7076 added document direction synchronization for an RTL Arabic layout. Arabic was later kept on an LTR layout because Studio still uses physical-direction CSS, but the root dir="ltr" assignment remained for every locale.

Sonner defines close-button variables under html[dir="ltr"], including a start position of zero. The Studio override used unset, which inherits for custom properties, so Sonner's root value won and placed the close button over the status icon.

This change removes the unused global direction mutation and uses auto for the close button's start position. The close button therefore remains pinned eight pixels from the right edge even if dir="ltr" or dir="rtl" is set later.

Before and after

Before this PR:

  • Every locale set a root direction.
  • Sonner inherited a left-edge close-button position.
  • Status icons and close buttons overlapped.
  • An external or future root direction could reproduce the overlap.
  • The language dropdown grew to about 440px and displayed all 12 choices at once.

After this PR:

  • Locale changes update lang without mutating global layout direction.
  • All 12 choices, including automatic detection and 11 supported locales, remain available.
  • The close button stays inside the top-right corner under no direction, LTR, RTL, and live direction changes.
  • Toast content, actions, and status icons do not overlap the close button.
  • The language dropdown is capped at 18rem, about 288px, and scrolls to reveal the remaining choices.

Scope and compatibility

This PR changes no backend, model, hardware, operating-system, packaging, or inference path. Existing supported paths are untouched. The language selector, automatic detection, persisted preferences, personalization synchronization, locale overlays, and per-element bidirectional text behavior remain intact. The dropdown cap is local to the language selector and does not affect shared dropdown components.

Testing

  • 568 toast assertions against real before and after builds
    • macOS: Chromium, installed Chrome, Firefox, WebKit 26.5, and isolated official Edge 150
    • Linux ARM64 container: Chromium, Firefox, and WebKit
    • Mobile, tablet, and desktop viewports
    • Eleven locales, light and dark themes, eight toast variants
    • Long text, Arabic, Hindi, CJK, mixed-direction text, and emoji
    • Stacking, dismissal, live resize, LTR, RTL, live direction changes, high DPI, forced colors, and normal motion
  • 50 language dropdown assertions across Chromium, installed Chrome, Firefox, WebKit, and isolated official Edge
    • Tall baseline reproduction and 18rem cap verification
    • Required overflow, wheel scrolling, scrolled selection, keyboard traversal, and touch selection
    • Viewports from 320px through 1440px wide, including a 320px short-height case
  • Linux Node 24 clean install, locale parity, typecheck, and production build
  • macOS production builds before and after
  • npm run i18n:check
  • npm run typecheck
  • npm run build
  • pytest -q tests/studio/test_locale_root_direction_contract.py on Python 3.10, 3.11, 3.12, and 3.13, with 3 passing tests on each version
  • Relevant pre-commit hooks, ESLint, formatting, and whitespace checks
  • Windows legacy-codec simulation confirming that explicit UTF-8 reads avoid the multilingual catalog failure mode

Native Safari automation requires the local Safari remote-automation permission, and native Windows validation remains covered by the repository's Windows CI runners.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request removes the automatic setting of the document's text direction (dir attribute) during locale synchronization and cleans up the unused dir metadata from the locales configuration. It also introduces a regression test suite to enforce this behavior. The review feedback recommends specifying encoding="utf-8" when reading files in the Python tests to avoid platform-dependent encoding issues, particularly since the localization files contain non-ASCII characters.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.



def test_locale_changes_do_not_force_document_direction():
src = LOCALE_STORE.read_text()

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.

medium

When reading files in Python, always specify encoding="utf-8" to prevent platform-dependent encoding failures (e.g., on Windows) where default codecs might fail on non-ASCII characters.

Suggested change
src = LOCALE_STORE.read_text()
src = LOCALE_STORE.read_text(encoding="utf-8")
References
  1. When opening and reading configuration files (such as tokenizer_config.json containing chat templates) in Python, always specify encoding='utf-8' to prevent platform-dependent encoding failures (e.g., on Windows) where default codecs might fail on non-ASCII characters.



def test_locale_metadata_does_not_advertise_unused_layout_direction():
src = MESSAGES.read_text()

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.

medium

When reading files in Python, always specify encoding="utf-8" to prevent platform-dependent encoding failures (e.g., on Windows) where default codecs might fail on non-ASCII characters. This is especially important here because messages.ts contains non-ASCII characters like Chinese, Japanese, Korean, Hindi, and Arabic.

Suggested change
src = MESSAGES.read_text()
src = MESSAGES.read_text(encoding="utf-8")
References
  1. When opening and reading configuration files (such as tokenizer_config.json containing chat templates) in Python, always specify encoding='utf-8' to prevent platform-dependent encoding failures (e.g., on Windows) where default codecs might fail on non-ASCII characters.

@shimmyshimmer
shimmyshimmer marked this pull request as ready for review July 15, 2026 13:23
@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 539d2feeba

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 705292ba5d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@shimmyshimmer
shimmyshimmer merged commit 300b5f9 into main Jul 15, 2026
38 of 40 checks passed
@shimmyshimmer
shimmyshimmer deleted the agent/fix-studio-toast-positioning branch July 15, 2026 14:43
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.

1 participant