Skip to content

Commit

Permalink
fix: Fixed Logistration page display
Browse files Browse the repository at this point in the history
  • Loading branch information
sundasnoreen12 committed Feb 25, 2025
1 parent c04ed9a commit ffb8695
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/common-components/FormGroup.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useEffect, useRef, useState } from 'react';

import {
Form, TransitionReplace,
Expand All @@ -7,6 +7,27 @@ import PropTypes from 'prop-types';

const FormGroup = (props) => {
const [hasFocus, setHasFocus] = useState(false);
const [isAutoFill, setIsAutoFill] = useState(true);
const inputRef = useRef(null);

useEffect(() => {
const observer = new MutationObserver(() => {
if (inputRef.current) {
const isAutoFillField = inputRef.current.matches(':autofill');
setIsAutoFill(isAutoFillField);
}
});

if (inputRef.current) {
observer.observe(inputRef.current, {
attributes: true,
childList: true,
subtree: true,
});
}

return () => observer.disconnect();
}, []);

const handleFocus = (e) => {
setHasFocus(true);
Expand All @@ -23,6 +44,7 @@ const FormGroup = (props) => {
return (
<Form.Group controlId={props.name} className={props.className} isInvalid={props.errorMessage !== ''}>
<Form.Control
ref={inputRef}
as={props.as}
readOnly={props.readOnly}
type={props.type}
Expand All @@ -39,6 +61,7 @@ const FormGroup = (props) => {
controlClassName={props.borderClass}
trailingElement={props.trailingElement}
floatingLabel={props.floatingLabel}
isAutoFill={isAutoFill}
>
{props.options ? props.options() : null}
</Form.Control>
Expand Down

0 comments on commit ffb8695

Please sign in to comment.