Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit c2100b0

Browse files
committed
Fixed: popups inside period details were overlaying container.
1 parent cdde4e3 commit c2100b0

File tree

4 files changed

+39
-6
lines changed

4 files changed

+39
-6
lines changed

src/components/Popup/index.jsx

+18-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,27 @@ import PT from "prop-types";
44
import cn from "classnames";
55
import compStyles from "./styles.module.scss";
66

7-
const Popup = ({ children, className, referenceElement }) => {
7+
/**
8+
* Displays a popup near the reference element.
9+
*
10+
* @param {Object} props component properties
11+
* @param {any} [props.children] child nodes
12+
* @param {string} [props.className] class name to be added to root element
13+
* @param {Object} props.referenceElement reference element
14+
* @param {'absolute'|'fixed'} [props.strategy] positioning strategy
15+
* @returns {JSX.Element}
16+
*/
17+
const Popup = ({
18+
children,
19+
className,
20+
referenceElement,
21+
strategy = "absolute",
22+
}) => {
823
const [popperElement, setPopperElement] = useState(null);
924
const [arrowElement, setArrowElement] = useState(null);
1025
const { styles, attributes } = usePopper(referenceElement, popperElement, {
1126
placement: "bottom",
12-
strategy: "fixed",
27+
strategy,
1328
modifiers: [
1429
{ name: "arrow", options: { element: arrowElement, padding: 10 } },
1530
{ name: "offset", options: { offset: [0, 5] } },
@@ -34,6 +49,7 @@ Popup.propTypes = {
3449
children: PT.node,
3550
className: PT.string,
3651
referenceElement: PT.object.isRequired,
52+
strategy: PT.oneOf(["absolute", "fixed"]),
3753
};
3854

3955
export default Popup;

src/routes/WorkPeriods/components/PaymentError/index.jsx

+9-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,15 @@ import styles from "./styles.module.scss";
1414
* @param {string} [props.className] class name to be added to root element
1515
* @param {Object} [props.errorDetails] error details object
1616
* @param {boolean} [props.isImportant] whether the error deemed important
17+
* @param {'absolute'|'fixed'} [props.popupStrategy] popup positioning strategy
1718
* @returns {JSX.Element}
1819
*/
19-
const PaymentError = ({ className, errorDetails, isImportant = true }) => {
20+
const PaymentError = ({
21+
className,
22+
errorDetails,
23+
isImportant = true,
24+
popupStrategy = "absolute",
25+
}) => {
2026
const [isShowPopup, setIsShowPopup] = useState(false);
2127
const [refElem, setRefElem] = useState(null);
2228
const containerRef = useRef(null);
@@ -42,7 +48,7 @@ const PaymentError = ({ className, errorDetails, isImportant = true }) => {
4248
tabIndex={0}
4349
/>
4450
{isShowPopup && errorDetails && (
45-
<Popup referenceElement={refElem}>
51+
<Popup referenceElement={refElem} strategy={popupStrategy}>
4652
<PaymentErrorDetails details={errorDetails} />
4753
</Popup>
4854
)}
@@ -54,6 +60,7 @@ PaymentError.propTypes = {
5460
className: PT.string,
5561
errorDetails: PT.object,
5662
isImportant: PT.bool,
63+
popupStrategy: PT.oneOf(["absolute", "fixed"]),
5764
};
5865

5966
export default PaymentError;

src/routes/WorkPeriods/components/PaymentTotal/index.jsx

+10-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,16 @@ import styles from "./styles.module.scss";
1717
* @param {Array} [props.payments] an array with payments information
1818
* @param {number} props.paymentTotal total paid sum
1919
* @param {number} props.daysPaid number of paid days
20+
* @param {'absolute'|'fixed'} [props.popupStrategy] popup positioning strategy
2021
* @returns {JSX.Element}
2122
*/
22-
const PaymentTotal = ({ className, payments, paymentTotal, daysPaid }) => {
23+
const PaymentTotal = ({
24+
className,
25+
payments,
26+
paymentTotal,
27+
daysPaid,
28+
popupStrategy = "absolute",
29+
}) => {
2330
const [isShowPopup, setIsShowPopup] = useState(false);
2431
const [refElem, setRefElem] = useState(null);
2532
const containerRef = useRef(null);
@@ -56,7 +63,7 @@ const PaymentTotal = ({ className, payments, paymentTotal, daysPaid }) => {
5663
<span className={styles.daysPaid}>({daysPaid})</span>
5764
</span>
5865
{hasPayments && isShowPopup && (
59-
<Popup referenceElement={refElem}>
66+
<Popup referenceElement={refElem} strategy={popupStrategy}>
6067
<PaymentsList payments={payments} />
6168
</Popup>
6269
)}
@@ -69,6 +76,7 @@ PaymentTotal.propTypes = {
6976
payments: PT.array,
7077
paymentTotal: PT.number.isRequired,
7178
daysPaid: PT.number.isRequired,
79+
popupStrategy: PT.oneOf(["absolute", "fixed"]),
7280
};
7381

7482
export default PaymentTotal;

src/routes/WorkPeriods/components/PeriodItem/index.jsx

+2
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,15 @@ const PeriodItem = ({
126126
className={styles.paymentError}
127127
errorDetails={data.paymentErrorLast}
128128
isImportant={data.paymentStatus !== PAYMENT_STATUS.COMPLETED}
129+
popupStrategy="fixed"
129130
/>
130131
)}
131132
<PaymentTotal
132133
className={styles.paymentTotalContainer}
133134
daysPaid={data.daysPaid}
134135
payments={data.payments}
135136
paymentTotal={data.paymentTotal}
137+
popupStrategy="fixed"
136138
/>
137139
</td>
138140
<td>

0 commit comments

Comments
 (0)