Skip to content

Language Switcher: Replace custom Dialog component with the core Modal. #103503

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 18, 2025

Conversation

sdnunca
Copy link
Contributor

@sdnunca sdnunca commented May 16, 2025

Fixes DOTCOM-12873

Proposed Changes

Replace the Dialog component with the core's Modal.

Why are these changes being made?

The previous modal was unnecessarily large.

Before:
image

After:
image

Testing Instructions

  • Visit /me/account, open the language switcher modal, and confirm it works correctly.

Pre-merge Checklist

  • Has the general commit checklist been followed? (PCYsg-hS-p2)
  • Have you written new tests for your changes?
  • Have you tested the feature in Simple (P9HQHe-k8-p2), Atomic (P9HQHe-jW-p2), and self-hosted Jetpack sites (PCYsg-g6b-p2)?
  • Have you checked for TypeScript, React or other console errors?
  • Have you used memoizing on expensive computations? More info in Memoizing with create-selector and Using memoizing selectors and Our Approach to Data
  • Have we added the "[Status] String Freeze" label as soon as any new strings were ready for translation (p4TIVU-5Jq-p2)?
    • For UI changes, have we tested the change in various languages (for example, ES, PT, FR, or DE)? The length of text and words vary significantly between languages.
  • For changes affecting Jetpack: Have we added the "[Status] Needs Privacy Updates" label if this pull request changes what data or activity we track or use (p4TIVU-aUh-p2)?

@sdnunca sdnunca requested a review from a team as a code owner May 16, 2025 16:00
@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label May 16, 2025
@sdnunca sdnunca requested a review from a team May 16, 2025 16:01
@matticbot
Copy link
Contributor

matticbot commented May 16, 2025

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

App Entrypoints (~31 bytes added 📈 [gzipped])

name                   parsed_size           gzip_size
entry-main                  +370 B  (+0.0%)       +1 B  (+0.0%)
entry-login                 +370 B  (+0.0%)      +30 B  (+0.0%)
entry-reauth-required       +185 B  (+0.0%)       +0 B

Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used.

Sections (~14 bytes added 📈 [gzipped])

name      parsed_size           gzip_size
settings        +92 B  (+0.0%)      -10 B  (-0.0%)
plugins         +92 B  (+0.0%)       +3 B  (+0.0%)
media           +92 B  (+0.0%)       +3 B  (+0.0%)
account         +92 B  (+0.0%)      +21 B  (+0.0%)

Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.

Async-loaded Components (~349 bytes added 📈 [gzipped])

name                                            parsed_size            gzip_size
async-load-calypso-lib-account-settings-helper     +16375 B  (+14.2%)    +5765 B  (+16.0%)
async-load-quick-language-switcher                 +16362 B  (+26.1%)    +5773 B  (+27.2%)
async-load-design-playground                          +92 B   (+0.0%)       +3 B   (+0.0%)
async-load-design-blocks                              +92 B   (+0.0%)       +3 B   (+0.0%)
async-load-design                                     +92 B   (+0.0%)       +3 B   (+0.0%)
async-load-calypso-post-editor-media-modal            +92 B   (+0.0%)       +3 B   (+0.0%)

React components that are loaded lazily, when a certain part of UI is displayed for the first time.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

@sdnunca sdnunca requested a review from a team May 16, 2025 16:51
@matticbot
Copy link
Contributor

matticbot commented May 16, 2025

This PR modifies the release build for the following Calypso Apps:

For info about this notification, see here: PCYsg-OT6-p2

  • blaze-dashboard
  • command-palette-wp-admin
  • help-center
  • notifications
  • odyssey-stats
  • wpcom-block-editor

To test WordPress.com changes, run install-plugin.sh $pluginSlug update/switch-language-switcher-to-core-modal on your sandbox.

Copy link
Contributor

@chriskmnds chriskmnds left a comment

Choose a reason for hiding this comment

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

Tested and it works! Left some code comments below.

flex:none;
flex-direction: column;
width: 100%;
>div:nth-child(2) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What are we targeting with this? Can we add a comment, or is there another way to be more explicit/clear? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added a comment, unfortunately, there's no easy way to add a class to the Modal HTML structure.

Copy link
Contributor

Choose a reason for hiding this comment

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

Heya. Replied below - #103503 (comment)
Let me know if you'll be confirming that, otherwise happy to explore further myself. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, I'm currently addressing the reported issues.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good. Happy to review any additional changes.

Comment on lines 27 to 30
display:flex;
flex:none;
flex-direction: column;
width: 100%;
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry for naive question. Are these effective/needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, with flex:none not being needed, I've removed the three instructions.

Seems to be a leftover from my previous attempt.

Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if removing any of these caused the breakage in #103503 (comment)

@sdnunca sdnunca merged commit aa01b6a into trunk May 18, 2025
13 of 14 checks passed
@sdnunca sdnunca deleted the update/switch-language-switcher-to-core-modal branch May 18, 2025 21:02
@github-actions github-actions bot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label May 18, 2025
@chriskmnds
Copy link
Contributor

I think some design is broken, or not fixed/ made worse.

This doesn't look ideal:

Screenshot 2025-05-19 at 11 42 52 AM

It was a little better before, but still modal too far stretched out.

Can you pls confirm?

display:flex;
/* Targeting the content div, we can't alter the HTML of the modal itself */
>div:nth-child(2) {
height: 100%;
Copy link
Contributor

Choose a reason for hiding this comment

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

Does height: 100% have any actual effect right now?

Sorry for my questions. CSS is not trivial to maintain.

margin-top: 24px;
display:flex;
/* Targeting the content div, we can't alter the HTML of the modal itself */
>div:nth-child(2) {
Copy link
Contributor

@chriskmnds chriskmnds May 19, 2025

Choose a reason for hiding this comment

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

In general, I think the more we can avoid referencing internal structures of external components, the better. These may change, even the core class names may change e.g. components-modal__content.

In this case, it looks we can achieve the same effect by wrapping the content we pass to the modal and target that instead, e.g.

<div className="language-picker__modal-content">
    <LanguagePicker
        headingTitle={ __( 'Select a language' ) }
        languages={ languages }
        languageGroups={ createLanguageGroups( __ ) }
        onSelectLanguage={ setSelectedLanguage }
        selectedLanguage={ selectedLanguage }
        localizedLanguageNames={ localizedLanguageNames }
    />
    <div>{ buttons }</div>
</div>

Targeting language-picker__modal-content would be safe(r).

But pls confirm. I only briefly tested.

We can drill into the need to even reference components-modal__content separately. That may be able to go away too.

@sdnunca
Copy link
Contributor Author

sdnunca commented May 19, 2025

Thanks for the report @chriskmnds, I'm currently addressing the issues, will have a PR up soon.

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