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

Form now scrolls up if warning is shown #699

Merged
merged 3 commits into from
Aug 12, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions web/src/components/storage/iscsi/DiscoverForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* find current contact information at www.suse.com.
*/

import React, { useEffect, useState } from "react";
import React, { useEffect, useRef, useState } from "react";
import {
Alert,
Form, FormGroup,
Expand All @@ -46,11 +46,21 @@ export default function DiscoverForm({ onSubmit: onSubmitProp, onCancel }) {
const [isLoading, setIsLoading] = useState(false);
const [isFailed, setIsFailed] = useState(false);
const [isValidAuth, setIsValidAuth] = useState(true);
const alertRef = useRef(null);

useEffect(() => {
setData(savedData);
}, [setData, savedData]);

useEffect(() => {
// Scroll the alert into view
if (isFailed)
alertRef.current.scrollIntoView({
behavior: "smooth",
block: "start"
});
});

const updateData = (key, value) => setData({ ...data, [key]: value });
const onAddressChange = v => updateData("address", v);
const onPortChange = v => updateData("port", v);
Expand Down Expand Up @@ -89,9 +99,15 @@ export default function DiscoverForm({ onSubmit: onSubmitProp, onCancel }) {
<Popup isOpen title="Discover iSCSI Targets">
<Form id={id} onSubmit={onSubmit}>
{ isFailed &&
<Alert variant="warning" isInline title="Something went wrong">
<p>Make sure you provide the correct values</p>
</Alert> }
<div ref={alertRef}>
<Alert
variant="warning"
isInline
title="Something went wrong"
>
<p>Make sure you provide the correct values</p>
</Alert>
</div> }
<FormGroup
fieldId="address"
label="IP address"
Expand Down
Loading