Skip to content
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

Fix/fe/field refactor #1173

Merged
merged 6 commits into from
Nov 22, 2024
Merged

Fix/fe/field refactor #1173

merged 6 commits into from
Nov 22, 2024

Conversation

ajhollid
Copy link
Collaborator

This PR addresses a concern @marcelluscaio and I noticed in the Create Infrastrucutre Monitors page.

The original implementation used the presence or abscence of a class name in the props of the Field component to enable or disable the default classes for the component.

The original implementaiton also used the presence or absecnce of a class name to disable showing errors for the Field.

I feel that this is dangerous and will lead to confusion if other devs want to specify class names for the Field component. It is not obvious that specifying a class name will disable the default styling for the component. Nor is it obvious that adding a class name will disable errors from showing.

I have modified the implementaitont to achieve the inteded results in a way that is explicit and obvious, which should reduce confusion and unintended outcomes.

  • Add the class name specified in props to the list of existing classnames rather than disabling all class names
    • Override the default styling to specify the min-width of the input
  • Add a hideErrorText prop to specify that errors should be hidden
  • Update JSdocs

This is a bandaid, and we should make refactoring the Field component a fairly high priority. It is not up to standard and there are multiple CSS files in the app modifying the component which is a nightmare for maintainability.

I will open an issue and work on this as soon as possible.

Copy link

coderabbitai bot commented Nov 21, 2024

Walkthrough

The changes in this pull request involve modifications to the Field component and its associated styles in the input fields. The CSS file adds a new rule for .field-infrastructure-alert, setting min-width: unset;. In the Field component, prop types and internal logic have been updated to include new props and default values, enhancing customization. Additionally, the CustomThreshold component has been adjusted to incorporate the hideErrorText property in its use of the Field component, with minor formatting improvements for clarity.

Changes

File Path Change Summary
Client/src/Components/Inputs/Field/index.css Added min-width: unset; to .field-infrastructure-alert class.
Client/src/Components/Inputs/Field/index.jsx Updated prop types and internal logic; added new props (onBlur, onInput, hideErrorText) with default values; modified error message display logic.
Client/src/Pages/Infrastructure/CreateMonitor/CustomThreshold/index.jsx Adjusted props destructuring for readability; added hideErrorText: true in Field component.

Possibly related PRs

  • fix: add css to fix the current password widget under account>password #940: The changes in the Field component in Client/src/Components/Inputs/Field/index.jsx include the addition of the onInput prop, which is relevant to the modifications made in the main PR regarding the Field component's props and functionality.
  • Hot fix/theme disabled #1161: The updates to the Field component's error message styling in this PR align with the changes made in the main PR, which also involve modifications to the Field component's props and visual feedback for error states.

Suggested reviewers

  • jennifer-gan
  • marcelluscaio

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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

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

🧹 Outside diff range and nitpick comments (6)
Client/src/Components/Inputs/Field/index.css (1)

Line range hint 1-7: Yo, we should document these CSS variables!

The code uses CSS variables like --env-var-width-3 and --env-var-width-4 but their values aren't immediately clear. Consider adding a comment block explaining these variables or linking to documentation.

Here's a suggested addition at the top of the file:

+/* Field component width variables:
+ * --env-var-width-3: Default minimum width for fields
+ * --env-var-width-4: Maximum width for infrastructure alert fields
+ */
.field {
  min-width: var(--env-var-width-3);
}
Client/src/Pages/Infrastructure/CreateMonitor/CustomThreshold/index.jsx (1)

Line range hint 1-92: Yo dawg, I heard you like refactoring! 🛠️

While these changes align with the immediate goals, I noticed from the PR objectives that a larger refactor is planned. Consider these points for the future refactor:

  1. The component's width is currently hardcoded to 50% - this might need to be more flexible
  2. The Stack and Box component nesting could potentially be simplified
  3. The error handling could be more standardized across all form components

Would you like me to create a GitHub issue to track these suggestions for the future refactor?

Client/src/Components/Inputs/Field/index.jsx (4)

10-34: Yo dawg, let's keep the param order consistent with PropTypes!

The documentation is solid, but the parameter order in JSDoc doesn't match the PropTypes declaration at the bottom of the file. Consider reordering them to maintain consistency and make it easier for developers to reference.


69-69: Consider using classnames library for more robust class handling

While the template literal works, using a dedicated class name utility like classnames or clsx would provide more robust handling of conditional classes and prevent potential issues with undefined className props.

Example usage:

-className={`${className} field field-${type}`}
+import classnames from 'classnames';
+className={classnames('field', `field-${type}`, className)}

198-202: Mom's spaghetti suggests a performance tweak! 🍝

Instead of using the HTML hidden attribute which still renders the DOM element, consider using conditional rendering for better performance.

-{error && (
+{error && !hideErrorText && (
   <Typography
     component="span"
     className="input-error"
-    hidden={hideErrorText}
     color={theme.palette.error.main}
     mt={theme.spacing(2)}
     sx={{
       opacity: 0.8,
     }}
   >
     {error}
   </Typography>
)}

237-238: Knees weak, arms heavy, but these PropTypes are ready! 💪

While the PropTypes are correctly defined, consider adding defaultProps for better documentation and type checking:

Field.defaultProps = {
  type: 'text',
  https: true,
  isRequired: false,
  isOptional: false,
  optionalLabel: '(optional)',
  disabled: false,
  hidden: false,
  hideErrorText: false,
};
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 27f651b and 992565f.

📒 Files selected for processing (3)
  • Client/src/Components/Inputs/Field/index.css (1 hunks)
  • Client/src/Components/Inputs/Field/index.jsx (5 hunks)
  • Client/src/Pages/Infrastructure/CreateMonitor/CustomThreshold/index.jsx (3 hunks)
🔇 Additional comments (5)
Client/src/Components/Inputs/Field/index.css (1)

6-6: Yo dawg, this change looks solid but let's verify the layout impact!

Setting min-width to 0 could affect how the field behaves in different containers. While this change aligns with the PR objectives, we should ensure it doesn't cause unexpected layout shifts.

✅ Verification successful

Yo, this layout change is straight fire! 🔥

The min-width: 0 override is specifically used in the infrastructure alert field within a flex container (justifyContent: "flex-end"), which is exactly where you'd want this behaviour to prevent field expansion. The change is:

  • Scoped only to .field-infrastructure-alert class
  • Used in a specific context in CustomThreshold component
  • Maintains other important styles like max-width and height constraints
  • Doesn't affect the base .field class which keeps its original min-width

No layout issues here, just straight-up proper CSS handling, eh!

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for any responsive layout tests or related components

# Look for related test files
fd -e test.jsx -e test.js -e spec.jsx -e spec.js | grep -i "field\|layout\|responsive"

# Search for related component usage
rg -l "field-infrastructure-alert"

Length of output: 240


Script:

#!/bin/bash
# Let's check the actual usage context of field-infrastructure-alert
rg -A 5 -B 5 "field-infrastructure-alert" Client/src/Pages/Infrastructure/CreateMonitor/CustomThreshold/index.jsx

# Also check if there are any layout-related styles or components that might be affected
rg -l "min-width" Client/src/Components/Inputs/Field/

# Let's see the full Field component CSS to understand the context better
cat Client/src/Components/Inputs/Field/index.css

Length of output: 1785

Client/src/Pages/Infrastructure/CreateMonitor/CustomThreshold/index.jsx (3)

Line range hint 8-22: Yo, these docs are straight fire! 🔥

The JSDoc formatting improvements make the documentation cleaner while maintaining all the essential information about the component's props and purpose.


26-35: These props be looking clean now! 👌

The consistent formatting and alignment of destructured props makes the code more readable. Nice cleanup!


60-70: Hold up, we need to verify something here! 🤔

The Field component changes look good with the addition of hideErrorText, but let's verify the CSS implementation:

Also, according to the PR objectives, class names should be additive rather than replacing defaults. Let's verify this behavior:

✅ Verification successful

The previous ast-grep pattern didn't work well. Let's try a more specific pattern:


Yo, the CSS implementation is on point! 🎯

Based on the CSS file inspection, the field-infrastructure-alert class is properly implemented with:

  • Correct min-width: 0 style
  • Additional styles for height and Material-UI components
  • Doesn't override the base .field class styles, but adds to them

The class follows the additive pattern since the base .field class remains intact with its own styles, and field-infrastructure-alert adds specific customizations on top.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for field-infrastructure-alert class definition
rg "field-infrastructure-alert" --type css

Length of output: 222


Script:

#!/bin/bash
# Search for Field component implementation to verify class handling
ast-grep --pattern 'className={$_}'

Length of output: 37


Script:

#!/bin/bash
# Let's check the Field component implementation to see how className is handled
rg -A 5 -B 5 "className.*field-infrastructure-alert" --type jsx

# Also check the CSS file content to verify the styles
cat Client/src/Components/Inputs/Field/index.css

Length of output: 1400


Script:

#!/bin/bash
# Search for Field component implementation
ast-grep --pattern 'const Field = ({ className, $$$}) => {
  $$$
}'

Length of output: 69


Script:

#!/bin/bash
# Let's try finding the Field component with ripgrep instead
rg -A 10 "const Field = \(" --type ts --type tsx --type jsx --type js

# Also check if there are any other files using this component to understand class handling
rg "import.*Field" --type ts --type tsx --type jsx --type js

Length of output: 190

Client/src/Components/Inputs/Field/index.jsx (1)

57-58: These props are straight fire! 🔥

The new props align perfectly with the PR objectives. Setting hideErrorText default to false maintains backward compatibility while allowing explicit control over error message visibility.

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 PR Summary

  • Business value and requirements alignment:

    • The PR aims to refactor the Field component to address concerns around the handling of class names and error messages.
    • Enhances maintainability and clarity, reducing potential confusion for developers.
    • Aligns with best practices by introducing explicit controls for error visibility and styling.
  • Key components modified:

    • Client/src/Components/Inputs/Field/index.jsx
    • Client/src/Components/Inputs/Field/index.css
    • Client/src/Pages/Infrastructure/CreateMonitor/CustomThreshold/index.jsx
  • Impact assessment:

    • Improves error handling and styling customization.
    • Enhances developer experience by making component behavior more explicit.
    • Impacts the CustomThreshold component, which uses the Field component.
  • System dependencies and integration impacts:

    • No significant changes to system design.
    • Changes are localized to the Field component and its usage in the CustomThreshold component.

1.2 Architecture Changes

  • System design modifications:

    • No significant changes to the system design.
  • Component interactions:

    • The Field component now has an additional prop hideErrorText, which affects how error messages are displayed.
  • Integration points:

    • Changes are localized to the Field component and its usage in the CustomThreshold component.

2. Detailed Technical Analysis

2.1 Code Logic Deep-Dive

Core Logic Changes

Client/src/Components/Inputs/Field/index.jsx
  • Submitted PR Code:

    const Field = forwardRef(
      (
        {
          type = "text",
          id,
          name,
          label,
          https,
          optionalLabel,
          autoComplete,
          placeholder,
          value,
          onChange,
          onBlur,
          onInput,
          error,
          disabled,
          hidden,
          className,
          hideErrorText = false,
        },
        ref
      ) => {
        const theme = useTheme();
    
        const [isVisible, setVisible] = useState(false);
    
        return (
          <Stack
            gap={theme.spacing(2)}
            className={`${className} field field-${type}`}
            sx={{
              "& fieldset": {
                borderColor: theme.palette.border.dark,
                borderRadius: theme.shape.borderRadius,
              },
              "&:not(:has(.Mui-disabled)):not(:has(.input-error)) .MuiOutlinedInput-root:hover:not(:has(input:focus)):not(:has(textarea:focus)) fieldset":
                {
                  borderColor: theme.palette.border.dark,
                },
              "&:has(.input-error) .MuiOutlinedInput-root fieldset": {
                borderColor: theme.palette.error.main,
              },
            }}
          >
            {/* Other code */}
            <Typography
              component="span"
              className="input-error"
              hidden={hideErrorText}
              color={theme.palette.error.main}
              mt={theme.spacing(2)}
              sx={{
                opacity: 0.8,
              }}
            >
              {error}
            </Typography>
          </Stack>
        );
      }
    );
  • Analysis:

    • The code introduces a new prop hideErrorText to control the visibility of error messages.
    • The className prop is now concatenated with existing class names instead of disabling all default classes.
    • The Typography component for error messages now uses the hideErrorText prop to control visibility.
  • LlamaPReview Suggested Improvements:

    const Field = forwardRef(
      (
        {
          type = "text",
          id,
          name,
          label,
          https,
          optionalLabel,
          autoComplete,
          placeholder,
          value,
          onChange,
          onBlur,
          onInput,
          error,
          disabled,
          hidden,
          className,
          hideErrorText = false,
        },
        ref
      ) => {
        const theme = useTheme();
    
        const [isVisible, setVisible] = useState(false);
    
        return (
          <Stack
            gap={theme.spacing(2)}
            className={`field field-${type} ${className}`}
            sx={{
              "& fieldset": {
                borderColor: theme.palette.border.dark,
                borderRadius: theme.shape.borderRadius,
              },
              "&:not(:has(.Mui-disabled)):not(:has(.input-error)) .MuiOutlinedInput-root:hover:not(:has(input:focus)):not(:has(textarea:focus)) fieldset":
                {
                  borderColor: theme.palette.border.dark,
                },
              "&:has(.input-error) .MuiOutlinedInput-root fieldset": {
                borderColor: theme.palette.error.main,
              },
            }}
          >
            {/* Other code */}
            {error && (
              <Typography
                component="span"
                className="input-error"
                hidden={hideErrorText}
                color={theme.palette.error.main}
                mt={theme.spacing(2)}
                sx={{
                  opacity: 0.8,
                }}
              >
                {error}
              </Typography>
            )}
          </Stack>
        );
      }
    );
  • Improvement Rationale:

    • Ensures that the className prop is correctly concatenated with existing class names.
    • Maintains the error check to conditionally render the error message.
    • Improves readability and maintainability.
Client/src/Components/Inputs/Field/index.css
  • Submitted PR Code:

    .field-infrastructure-alert {
      min-width: 0;
      max-width: var(--env-var-width-4);
    }
  • Analysis:

    • Overrides the default min-width for infrastructure alert fields to improve flexibility.
  • LlamaPReview Suggested Improvements:

    .field-infrastructure-alert {
      min-width: 0;
      max-width: var(--env-var-width-4);
    }
  • Improvement Rationale:

    • No changes needed; the override is necessary for the intended functionality.
Client/src/Pages/Infrastructure/CreateMonitor/CustomThreshold/index.jsx
  • Submitted PR Code:

    <Field
      type="number"
      className="field-infrastructure-alert"
      id={fieldId}
      value={infrastructureMonitor[fieldId]}
      onBlur={onFieldBlur}
      onChange={onFieldChange}
      error={errors[fieldId]}
      disabled={!infrastructureMonitor[checkboxId]}
      hideErrorText={true}
    ></Field>
  • Analysis:

    • Uses the new hideErrorText prop to hide error messages for the Field component.
  • LlamaPReview Suggested Improvements:

    <Field
      type="number"
      className="field-infrastructure-alert"
      id={fieldId}
      value={infrastructureMonitor[fieldId]}
      onBlur={onFieldBlur}
      onChange={onFieldChange}
      error={errors[fieldId]}
      disabled={!infrastructureMonitor[checkboxId]}
      hideErrorText={true}
    ></Field>
  • Improvement Rationale:

    • No changes needed; the usage of the hideErrorText prop is correct and aligns with the intended functionality.

2.2 Implementation Quality

  • Code organization and structure:

    • The code is well-organized, with clear separation of concerns.
    • The Field component is modular and reusable.
  • Error handling approach:

    • Error messages are now explicitly controlled using the hideErrorText prop.
    • Improves clarity and reduces potential confusion.
  • Performance considerations:

    • The changes are relatively minor and should not impact performance significantly.
    • The use of conditional rendering for error messages ensures that unnecessary elements are not rendered.

3. Critical Findings

3.1 Potential Issues

  • Critical Issues:

    • None identified.
  • Warnings:

    • None identified.

3.2 Code Quality Concerns

  • Maintainability aspects:
    • Ensure that the updated JSdocs accurately reflect the changes made to the Field component.
    • Consider adding examples of how to use the new hideErrorText prop.

4. Security Assessment

4.1 Security Considerations

  • Authentication/Authorization impacts:

    • No significant changes to authentication or authorization mechanisms.
  • Data handling concerns:

    • No new data handling concerns introduced.
  • Input validation:

    • No changes affecting input validation.
  • Security best practices:

    • The changes adhere to security best practices.

4.2 Vulnerability Analysis

  • Potential security risks:

    • None identified.
  • Mitigation strategies:

    • No additional mitigation strategies required.
  • Security testing requirements:

    • Ensure that existing security tests cover the modified components.

5. Testing Strategy

5.1 Test Coverage

  • Unit test analysis:

    • Update unit tests to cover the new hideErrorText prop.
    • Ensure that all edge cases related to the new prop are covered.
  • Integration test requirements:

    • Ensure that the Field component behaves as expected in the CustomThreshold component.
    • Cover scenarios where error messages are hidden or displayed based on the hideErrorText prop.

5.2 Test Recommendations

Suggested Test Cases

// Example unit test for hideErrorText prop
it('should hide error message when hideErrorText is true', () => {
  const { getByText } = render(
    <Field error="Error message" hideErrorText={true} />
  );
  expect(getByText('Error message')).toHaveAttribute('hidden');
});

it('should display error message when hideErrorText is false', () => {
  const { getByText } = render(
    <Field error="Error message" hideErrorText={false} />
  );
  expect(getByText('Error message')).not.toHaveAttribute('hidden');
});
  • Coverage improvements:

    • Ensure that the test coverage includes edge cases related to the new prop.
  • Performance testing needs:

    • No significant performance testing needs identified.

6. Documentation & Maintenance

  • Documentation updates needed (API, architecture, configuration):

    • Update JSdocs to accurately reflect the changes made to the Field component.
    • Add examples of how to use the new hideErrorText prop.
  • Long-term maintenance considerations:

    • The refactoring reduces technical debt and improves the component's maintainability.
    • Ensure that any future changes to the Field component are well-documented and tested.
  • Technical debt and monitoring requirements:

    • Continuously monitor the usage of the Field component to identify any potential issues.
    • Address any technical debt related to the Field component in future iterations.

7. Summary & Recommendations

7.1 Key Action Items

  1. Critical changes required:

    • None identified.
  2. Important improvements suggested:

    • None identified.
  3. Best practices to implement:

    • Ensure that the updated JSdocs accurately reflect the changes made to the Field component.
    • Consider adding examples of how to use the new hideErrorText prop.
  4. Cross-cutting concerns to address:

    • Ensure that the Field component behaves as expected in the CustomThreshold component.
    • Update unit tests to cover the new hideErrorText prop.

7.2 Future Considerations

  • Technical evolution path:

    • Continuously monitor the usage of the Field component to identify any potential issues.
    • Address any technical debt related to the Field component in future iterations.
  • Business capability evolution:

    • The refactoring aligns with the business requirements and improves the user experience for developers.
  • System integration impacts:

    • Ensure that any future changes to the Field component are well-documented and tested.

💡 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
Contributor

@jennifer-gan jennifer-gan Nov 21, 2024

Choose a reason for hiding this comment

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

I think it would be good to have field-infrastructure-alert inherit everything from field like below in index.css file:
.field .field-infrastructure-alert {
min-width: unset;
max-width: var(--env-var-width-4);
}

then in index.jsx , change to className={field field-${type} ${className}}
so that only override in case of infrastructure monitoring when className has the value, but still have all the css the .field possess

Copy link
Collaborator Author

@ajhollid ajhollid Nov 22, 2024

Choose a reason for hiding this comment

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

@jennifer-gan it already inerits everyting from the index.css file, adding the .field selector only increases the specificity 🤔 That's not a bad thing here but I don't think it adds anything.

Or were you referring to setting min-width to unset vs 0? Setting it to unset is probably a better idea, will update.

I'll update the order of classnames as suggested above though, that's a good point 👍

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: 1

🧹 Outside diff range and nitpick comments (3)
Client/src/Components/Inputs/Field/index.jsx (3)

10-34: Yo dawg, these docs are fire but they're missing some examples! 🔥

The documentation is comprehensive, but adding usage examples would help developers understand the component better, especially with the new hideErrorText prop and class name behaviour.

Add examples like:

// Basic usage
<Field
  type="text"
  id="username"
  value={username}
  onChange={handleChange}
/>

// With error handling
<Field
  type="email"
  id="email"
  value={email}
  error="Invalid email"
  hideErrorText={false}
  className="custom-field"
/>

237-238: Let's make these props default like mom's spaghetti! 🍝

While the PropTypes are correctly defined, consider adding defaultProps for better maintainability and documentation.

Add this after the PropTypes definition:

Field.defaultProps = {
  type: 'text',
  https: true,
  isRequired: false,
  isOptional: false,
  optionalLabel: '(optional)',
  disabled: false,
  hidden: false,
  hideErrorText: false,
  className: '',
};

Line range hint 1-241: Let's plan that future refactor! 🎯

Since this is a temporary solution, here are some suggestions for the comprehensive refactor:

  1. Consider using a CSS-in-JS solution to eliminate multiple CSS files
  2. Implement a design system with consistent input field variants
  3. Use CSS custom properties for theming instead of direct values
  4. Consider splitting into smaller components (e.g., separate password field)

Would you like me to create a GitHub issue to track these refactoring tasks?

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 992565f and b8d3910.

📒 Files selected for processing (2)
  • Client/src/Components/Inputs/Field/index.css (1 hunks)
  • Client/src/Components/Inputs/Field/index.jsx (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Client/src/Components/Inputs/Field/index.css
🔇 Additional comments (1)
Client/src/Components/Inputs/Field/index.jsx (1)

69-69: Straight fire className implementation! 🎯

The new className concatenation ensures default styles are preserved while allowing custom overrides. This aligns perfectly with the PR objectives.

Comment on lines 198 to 202
{error && (
<Typography
component="span"
className="input-error"
hidden={className? true: false}
hidden={hideErrorText}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Yo, we need to fix this accessibility issue! 🚨

Using the HTML hidden attribute for error text isn't ideal for screen readers. Consider using CSS display: none or aria-hidden with proper ARIA attributes.

Here's a suggested fix:

 {error && (
   <Typography
     component="span"
     className="input-error"
-    hidden={hideErrorText}
+    sx={{
+      display: hideErrorText ? 'none' : 'block',
+      opacity: 0.8,
+    }}
     color={theme.palette.error.main}
     mt={theme.spacing(2)}
-    sx={{
-      opacity: 0.8,
-    }}
   >
     {error}
   </Typography>
 )}

Committable suggestion skipped: line range outside the PR's diff.

@ajhollid
Copy link
Collaborator Author

I'm going to merge this as it is essentially identical to @jennifer-gan 's previous PR fixing this issue which I've already merged.

The only addition here is a prop to hide the error text. This will be refactored soon with the Field refactor anyways.

@ajhollid ajhollid merged commit a84916f into develop Nov 22, 2024
2 checks passed
@ajhollid ajhollid deleted the fix/fe/field-refactor branch November 22, 2024 01:33
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.

2 participants