-
Notifications
You must be signed in to change notification settings - Fork 709
fix: Use OR and strict equality in js/main.js #2347
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
base: master
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for mesheryio-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Summary of ChangesHello @grumi54, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves a bug that prevented the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
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 correctly fixes a logical bug where two mutually exclusive conditions were combined with an AND operator, preventing the code block from ever executing. The change to use an OR operator and strict equality is a good improvement. I've added one suggestion to further modernize the code for better readability and maintainability.
var scrollBuffer = 50; | ||
|
||
if ( | ||
window.location.pathname == "/" && | ||
window.location.pathname === "/" || | ||
window.location.pathname.includes("/programs") | ||
) { | ||
scrollBuffer = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While the logical fix is correct, this block can be modernized for better readability and to follow current best practices:
- Use
let
instead ofvar
for block-scoped variables that are reassigned. - Store
window.location.pathname
in aconst
to avoid repeating the property access. This makes theif
condition cleaner and easier to read.
const { pathname } = window.location;
let scrollBuffer = 50;
if (pathname === "/" || pathname.includes("/programs")) {
scrollBuffer = 0;
}
Signed-off-by: grumi54 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @grumi54.
@grumi54 @saurabhraghuvanshii, have we confirmed that the OR, not AND has no ill-effects on any other pages in which users visiting with a trailing forward slash?
Description
The branch that sets scrollBuffer = 0 could never run: it required pathname === "/" and pathname.includes("/programs") simultaneously—mutually exclusive. This caused header-shadow never to activate with zero buffer on home or programs pages. Updated to use OR and strict equality.