Skip to content

[app-bar] Fix optional chaining in joinVars function#47739

Merged
sai6855 merged 3 commits intomui:masterfrom
sai6855:appbar-tiny
Feb 10, 2026
Merged

[app-bar] Fix optional chaining in joinVars function#47739
sai6855 merged 3 commits intomui:masterfrom
sai6855:appbar-tiny

Conversation

@sai6855
Copy link
Copy Markdown
Member

@sai6855 sai6855 commented Feb 10, 2026

Fix optional chaining in joinVars function

@mui-bot
Copy link
Copy Markdown

mui-bot commented Feb 10, 2026

Netlify deploy preview

https://deploy-preview-47739--material-ui.netlify.app/

Bundle size report

Bundle Parsed size Gzip size
@mui/material ▼-1B(0.00%) ▼-1B(0.00%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/system 0B(0.00%) 0B(0.00%)
@mui/utils 0B(0.00%) 0B(0.00%)

Details of bundle changes

Generated by 🚫 dangerJS against 3591817


// var2 is the fallback.
// Ex. var1: 'var(--a)', var2: 'var(--b)'; return: 'var(--a, var(--b))'
const joinVars = (var1, var2) => (var1 ? `${var1?.replace(')', '')}, ${var2})` : var2);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Optional chaining is not required here since var1 will always be truthy when var1.replace runs

@sai6855 sai6855 marked this pull request as ready for review February 10, 2026 11:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts the joinVars helper in AppBar to remove redundant optional chaining, ensuring the function consistently treats var1 as a string when it is present and avoids silently producing "undefined, ..." output.

Changes:

  • Remove optional chaining from var1?.replace(...) inside joinVars.
  • Keep existing fallback behavior when var1 is falsy.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@zannager zannager added the scope: app bar Changes related to the app bar. label Feb 10, 2026
@ZeeshanTamboli ZeeshanTamboli added the type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature. label Feb 10, 2026
@ZeeshanTamboli ZeeshanTamboli changed the title [AppBar] Fix optional chaining in joinVars function [app-bar] Fix optional chaining in joinVars function Feb 10, 2026
@sai6855 sai6855 merged commit 5c32c2c into mui:master Feb 10, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: app bar Changes related to the app bar. type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants