Skip to content

Conversation

@mdoggydog
Copy link
Contributor

@mdoggydog mdoggydog commented Jul 29, 2025

  • Tell the MW core that this skin supports responsive behavior.
  • Stop manually emitting a "viewport" meta tag from Chameleon.

MW Skin always emits a "viewport" meta tag --- but it needs to know if a skin supports responsive behavior in order to emit the correct tag.

On top of that, the additional tag which Chameleon was emitting was either redundant, or had different/competing values for width (so some mobile browsers still performed non-responsive rendering, despite the extra tag).

Summary by CodeRabbit

  • New Features

    • Improved responsive behavior for mobile browsers by enabling a responsive setting for the Chameleon skin.
  • Refactor

    • Updated the way responsive support is configured for the Chameleon skin, streamlining its initialization process.

…ssionalWiki#470)

 * Tell the MW core that this skin supports responsive behavior.
 * Stop manually emitting a "viewport" meta tag from Chameleon.

MW `Skin` always emits a "viewport" meta tag --- but it needs to know if
a skin supports responsive behavior in order to emit the correct tag.

On top of that, the additional tag which `Chameleon` was emitting was either
redundant, or had different/competing values for `width` (so some mobile
browsers still performed non-responsive rendering, despite the extra tag).
@coderabbitai
Copy link

coderabbitai bot commented Jul 29, 2025

📝 Walkthrough

Walkthrough

The changes remove the initPage method from the Chameleon class, which previously set a viewport meta tag for responsive design. Instead, the Chameleon skin is now registered with a 'responsive' => true flag via its constructor, shifting responsibility for responsive behavior configuration.

Changes

Cohort / File(s) Change Summary
Chameleon class update
src/Chameleon.php
Removed the initPage(OutputPage $out) method, eliminating explicit viewport meta tag handling.
Skin registration modification
src/Hooks/SetupAfterCache.php
Added 'responsive' => true to the Chameleon constructor in registerSkinWithMW.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Possibly related issues

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e5145f6 and 1d39626.

📒 Files selected for processing (2)
  • src/Chameleon.php (0 hunks)
  • src/Hooks/SetupAfterCache.php (1 hunks)
💤 Files with no reviewable changes (1)
  • src/Chameleon.php
🔇 Additional comments (1)
src/Hooks/SetupAfterCache.php (1)

242-242: LGTM! Proper implementation of responsive skin declaration.

This change correctly declares the Chameleon skin as responsive to MediaWiki core, which will handle viewport meta tag emission appropriately. This is the proper way to enable responsive behavior in MediaWiki skins.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

return new Chameleon( [
'name' => 'chameleon',
'styles' => $styles,
'responsive' => true,
Copy link
Member

Choose a reason for hiding this comment

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

Is this a new MediaWiki feature? Since when is it available?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's been there "for a while". As far as Chameleon support is concerned, it's available in MW 1.39+.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From a quick git blame, it looks like emitting the viewport tag for a true responsive option goes back to at least 2020-08-03 (204ddf052296), and emitting the fixed-width viewport tag for the non-responsive case was first added 2 years later, in 2022-05-09 (f5afb5c48c9a). (So, 2022-05 is when the two competing viewport tags would have started appearing in the HTML output with Chameleon.)

parent::initPage( $out );

// Enable responsive behaviour on mobile browsers
$out->addMeta( 'viewport', 'width=device-width, initial-scale=1, shrink-to-fit=no' );
Copy link
Contributor

@malberts malberts Jul 30, 2025

Choose a reason for hiding this comment

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

This is based on Bootstrap 4's recommended meta tag:
https://getbootstrap.com/docs/4.6/getting-started/introduction/#responsive-meta-tag

Can you confirm that the difference between that and MediaWiki's tag does not cause issues or changes in mobile behavior?

..., shrink-to-fit=no"/>
..., user-scalable=yes, minimum-scale=0.25, maximum-scale=5.0"/>

(from #470 (comment))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

FWIW, my (limited) understanding is that shrink-to-fit is a 10-year-old Safari-specific "band-aid": https://www.scottohara.me/blog/2018/12/11/shrink-to-fit.html

Conversely, user-scalable=yes is the default value for viewport meta tags. (And the default min/max are 0.1 and 10, according to MDN.)

(As far as real-world testing, all I did is check that the PR made my observed misbehavior go away, on a handful of browsers on Android.)

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.

Chameleon does not declare itself "responsive" to MW core, and produces an extra/ambiguous viewport meta tag

3 participants