Skip to content

REFACTOR: added sticky behaviour to the save button at the end #2331

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

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

Thirukumaran-T
Copy link

@Thirukumaran-T Thirukumaran-T commented May 24, 2025

I have added sticky behaviour to the save button in the settings page

Fixes #2257

  • I deployed the application locally.
  • [x]I have performed a self-review and testing of my code.
  • I have included the issue Save button enhancement #2257 in the PR.
  • I have added i18n support to visible strings (instead of <div>Add</div>, use):
const { t } = useTranslation();
<div>{t('add')}</div>
  • I have not included any files that are not related to my pull request, including package-lock and package-json if dependencies have not changed
  • I didn't use any hardcoded values (otherwise it will not scale, and will make it difficult to maintain consistency across the application).
  • My PR is granular and targeted to one specific feature.
  • [x]
    settings page one
    I took a screenshot or a video and attached to this PR if there is a UI change.
    settings page two

Summary by CodeRabbit

  • Style
    • Made the save button area on the Settings page sticky and visually distinct, ensuring it remains visible at the bottom of the screen while scrolling.

Copy link

coderabbitai bot commented May 24, 2025

Walkthrough

A style object was added to the Stack component wrapping the save button on the Settings page. This update makes the save button area sticky at the bottom of the viewport, with theme-based colors, spacing, box shadow, and high z-index, ensuring visibility while scrolling through long forms.

Changes

File(s) Change Summary
client/src/Pages/Settings/index.jsx Added sticky positioning and theme-based styling to the Stack wrapping the save button for visibility.

Assessment against linked issues

Objective Addressed Explanation
Make the "Save" button sticky and visible while scrolling the form (#2257, #2060)
Use theme-based colors, spacing, and avoid hardcoded values (#2257)
No changes to exported/public entity signatures (#2257)
PR is granular, targeted, and includes i18n support where needed (#2257)

Why did the Canadian developer make the save button sticky?
Because they didn’t want it to “eh”-scape the user’s view, even when scrolling down!


📜 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 76d6900 and 9ce1bf9.

📒 Files selected for processing (1)
  • client/src/Pages/Settings/index.jsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • client/src/Pages/Settings/index.jsx
✨ Finishing Touches
  • 📝 Generate Docstrings

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 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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
client/src/Pages/Settings/index.jsx (1)

197-197: Fix spacing syntax for consistency.

There's a small spacing inconsistency that would make any Canadian apologize profusely - you have mt : 3 with spaces around the colon, while other properties use mt: theme.spacing(2) format consistently.

-					mt : 3,
+					mt: theme.spacing(3),
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9681c7e and 76d6900.

📒 Files selected for processing (1)
  • client/src/Pages/Settings/index.jsx (1 hunks)
🔇 Additional comments (1)
client/src/Pages/Settings/index.jsx (1)

192-205:

❓ Verification inconclusive

Address styling redundancy and verify color contrast for accessibility.

The sticky implementation looks solid, eh! Just like how Americans stick to their healthcare bills, this button will stick to the bottom. However, there are a few concerns:

  1. Redundant justifyContent: You've specified justifyContent="flex-end" as a prop (line 191) and again in the sx object (line 200). The sx prop will override the component prop, so the prop is redundant.

  2. Color contrast concern: Using theme.palette.primary.main as background might create poor contrast with the accent-colored button, potentially affecting accessibility.

  3. High z-index: The z-index of 1000 is quite high and might conflict with modal overlays or tooltips that typically use similar or higher values.

Apply this diff to address the redundancy and improve maintainability:

			<Stack
				direction="row"
-				justifyContent="flex-end"
				sx={{
					position: "sticky",
					bottom: 0,
					boxShadow: theme.shape.boxShadow,
					zIndex: 1000,
					mt : 3,
-					backgroundColor: theme.palette.primary.main,
+					backgroundColor: theme.palette.background.paper,
					display: "flex",
					justifyContent: "flex-end",
					pb: theme.spacing(5),
					pr: theme.spacing(15),
					pl: theme.spacing(5),
					pt: theme.spacing(5),
				}}
			>

Please verify the color contrast meets WCAG guidelines:


🏁 Script executed:

#!/bin/bash
# Description: Search for theme color definitions to verify contrast ratios
# Expected: Find theme definitions to assess primary.main vs accent color contrast

echo "Searching for theme color definitions..."
rg -A 10 -B 5 "palette.*primary.*main|palette.*accent" --type js --type jsx --type ts --type tsx

echo "Searching for accent color definition..."
rg -A 5 -B 5 "accent.*color|color.*accent" --type js --type jsx --type ts --type tsx

Length of output: 423


Our previous search was more stubborn than a Canadian apologizing—let’s try using filename globs instead of --type.


🏁 Script executed:

#!/bin/bash
# Locate theme configuration files
echo "🔍 Searching for files that define or use a theme..."
rg --files-with-matches "createTheme|ThemeProvider" -g '*.js' -g '*.jsx' -g '*.ts' -g '*.tsx'

# Search for palette definitions across all JS/TS files
echo -e "\n🔎 Scanning for palette.primary.main and palette.accent..."
rg -A 10 -B 5 "palette.*primary.*main|palette.*accent" -g '*.js' -g '*.jsx' -g '*.ts' -g '*.tsx'

# Also look specifically for any “accent” color aliases
echo -e "\n✨ Looking for accent color usages..."
rg -A 5 -B 5 "accent.*color|color.*accent" -g '*.js' -g '*.jsx' -g '*.ts' -g '*.tsx'

Length of output: 86345


Let’s pull the actual hex values for primary.main and accent.main from your theme files so we can compute the contrast ratios.


🏁 Script executed:

#!/bin/bash
# Extract primary.main and accent.main from light & dark themes

echo "🔍 lightTheme.js – primary.main"
rg -n "primary\s*:\s*{[^}]*main" -A2 client/src/Utils/Theme/lightTheme.js

echo -e "\n🔍 lightTheme.js – accent.main"
rg -n "accent\s*:\s*{[^}]*main" -A2 client/src/Utils/Theme/lightTheme.js

echo -e "\n🔍 darkTheme.js – primary.main"
rg -n "primary\s*:\s*{[^}]*main" -A2 client/src/Utils/Theme/darkTheme.js

echo -e "\n🔍 darkTheme.js – accent.main"
rg -n "accent\s*:\s*{[^}]*main" -A2 client/src/Utils/Theme/darkTheme.js

Length of output: 1085


Let’s pull the full primary and accent blocks (hex values included) from both theme files—this is easier than convincing an American to apologize, eh?


🏁 Script executed:

#!/bin/bash
echo "🔍 Dumping primary & accent blocks from theme files"
for file in client/src/Utils/Theme/lightTheme.js client/src/Utils/Theme/darkTheme.js; do
  echo -e "\n📋 $file – Primary definitions:"
  sed -n '/primary\s*:/,/},/p' "$file"
  echo -e "\n📋 $file – Accent definitions:"
  sed -n '/accent\s*:/,/},/p' "$file"
done

Length of output: 1110


Let’s inspect the actual structure of your theme files to locate the palette definitions:


🏁 Script executed:

#!/bin/bash
echo "🌞 client/src/Utils/Theme/lightTheme.js (first 200 lines):"
sed -n '1,200p' client/src/Utils/Theme/lightTheme.js

echo -e "\n🌜 client/src/Utils/Theme/darkTheme.js (first 200 lines):"
sed -n '1,200p' client/src/Utils/Theme/darkTheme.js

Length of output: 1108


Harmonize sticky bar styling & verify contrast

Remove redundant props and align with MUI’s z-index scale:

  • File: client/src/Pages/Settings/index.jsx
    • Remove justifyContent="flex-end" (it’s overridden by sx)
    • Replace zIndex: 1000 with zIndex: theme.zIndex.appBar
    • Swap backgroundColor: theme.palette.primary.main for theme.palette.background.paper
   <Stack
     direction="row"
-    justifyContent="flex-end"
     sx={{
       position: "sticky",
       bottom: 0,
       boxShadow: theme.shape.boxShadow,
-      zIndex: 1000,
+      zIndex: theme.zIndex.appBar,
       mt: 3,
-      backgroundColor: theme.palette.primary.main,
+      backgroundColor: theme.palette.background.paper,
       display: "flex",
       justifyContent: "flex-end",
       pb: theme.spacing(5),
       pr: theme.spacing(15),
       pl: theme.spacing(5),
       pt: theme.spacing(5),
     }}
   >

Canada’s politeness aside, let’s make sure your accent-coloured button still meets WCAG 2.1 AA (4.5:1) against the new background—please confirm the contrast ratio.

Copy link

@llamapreview llamapreview bot left a comment

Choose a reason for hiding this comment

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

Auto Pull Request Review from LlamaPReview

1. Overview

1.1 Core Changes

  • Primary purpose and scope: Implement sticky behavior for save button in Settings page to enhance UX
  • Key components modified: client/src/Pages/Settings/index.jsx Stack component styling
  • Cross-component impacts: None - isolated UI change
  • Business value alignment: Improves user experience for configuration management (aligned with Save button enhancement #2257)

1.2 Technical Architecture

  • System design modifications: Pure CSS styling change using Material UI's sx prop
  • Component interaction changes: No functional changes to component relationships
  • Integration points impact: None
  • Dependency changes: No new dependencies introduced

2. Critical Findings

2.1 Must Fix (P0🔴)

No critical issues found

2.2 Should Fix (P1🟡)

Issue: Excessive top margin on Save button causes layout imbalance

  • Analysis Confidence: High
  • Impact: Creates unnecessary whitespace in sticky footer, reduces visual hierarchy
  • Suggested Solution: Remove mt: theme.spacing(20) from Button sx prop

Issue: Potentially distracting background color choice

  • Analysis Confidence: Medium
  • Impact: Primary color background might be visually overwhelming
  • Suggested Solution: Use neutral background (e.g., theme.palette.background.paper)

2.3 Consider (P2🟢)

Area: Sticky container margin and padding

  • Analysis Confidence: High
  • Improvement Opportunity: Simplify layout logic by reviewing mt: 3 and pr: 15 values

2.4 Summary of Action Items

  1. Remove excessive button margin (P1 - immediate)
  2. Adjust background color (P1 - immediate)
  3. Review sticky container spacing (P2 - next sprint)

3. Technical Analysis

3.1 Code Logic Analysis

📁 client/src/Pages/Settings/index.jsx - Save Button Stack

  • Submitted PR Code:
    <Stack
      direction="row"
      justifyContent="flex-end"
      sx={{
        position: "sticky",
        bottom: 0,
        boxShadow: theme.shape.boxShadow,
        zIndex: 1000,
        mt: 3,
        backgroundColor: theme.palette.primary.main,
        pb: theme.spacing(5),
        pr: theme.spacing(15),
        pl: theme.spacing(5),
        pt: theme.spacing(5),
      }}
    >
      <Button
        sx={{ px: theme.spacing(12), mt: theme.spacing(20) }}
      >
        {t("settingsSave")}
      </Button>
    </Stack>
  • Analysis:
    • Current margin/padding combination creates vertical spacing conflict
    • Sticky container's pt/pb vs button's mt creates redundant spacing
    • Primary color background might clash with content during scrolling
  • LlamaPReview Suggested Improvements:
    <Stack
      direction="row"
      justifyContent="flex-end"
      sx={{
        position: "sticky",
        bottom: 0,
        boxShadow: theme.shape.boxShadow,
        zIndex: 1000,
        backgroundColor: theme.palette.background.paper, // Neutral background
        py: theme.spacing(3),  // Balanced vertical padding
        px: theme.spacing(5),  // Consistent horizontal padding
      }}
    >
      <Button
        sx={{ px: theme.spacing(12) }} // Removed mt
      >
        {t("settingsSave")}
      </Button>
    </Stack>
  • Improvement rationale:
    • Technical benefits: Simplifies spacing logic, improves maintainability
    • Business value: Cleaner UI presentation enhances user experience
    • Risk assessment: Low risk - preserves core sticky functionality

3.2 Key Quality Aspects

  • Testing strategy: Consider visual regression tests for sticky behavior
  • Documentation: Update style guide with sticky component patterns

4. Overall Evaluation

  • Technical assessment: Well-scoped UI improvement with minor styling refinements needed
  • Business impact: Direct user experience enhancement for critical configuration page
  • Risk evaluation: Low risk with suggested changes
  • Notable positive aspects: Good use of theme variables, proper z-index handling
  • Implementation quality: 85% complete - requires final styling polish
  • Final recommendation: Request Changes (Address P1 items before approval)

💡 LlamaPReview Community
Have feedback on this AI Code review tool? Join our GitHub Discussions to share your thoughts and help shape the future of LlamaPReview.

Copy link
Collaborator

@ajhollid ajhollid left a comment

Choose a reason for hiding this comment

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

The implementation looks fine, but I'm not sure about the design side of things.

The bar covers the border of settings items on one side and not the other 🤔

image

@gorkem-bwl can you drop your thoughts on design here? Maybe the save bar needs the same border as other settings items?

@gorkem-bwl
Copy link
Contributor

The implementation looks fine, but I'm not sure about the design side of things.

The bar covers the border of settings items on one side and not the other 🤔
@gorkem-bwl can you drop your thoughts on design here? Maybe the save bar needs the same border as other settings items?

@Thirukumaran-T can you please send a video here so I can check? Also can you make it thinner as I indicated earlier, and then send the video?

image

@Thirukumaran-T
Copy link
Author

I have made them thinner and updated the PR

checkmate.mp4

@Thirukumaran-T Thirukumaran-T requested a review from ajhollid May 28, 2025 05:52
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