Skip to content

Commit

Permalink
fix: Naprawiono bład w formularzu (#120)
Browse files Browse the repository at this point in the history
Co-authored-by: Michał Miszczyszyn <mmiszy@users.noreply.github.com>
Co-authored-by: Adam Siekierski <a@siekierski.ml>
  • Loading branch information
3 people committed Jan 7, 2021
1 parent 05992f8 commit bbf171c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion components/UpdateBlogSection/UpdateBlogForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export const UpdateBlogForm = memo<Props>(({ blogId }) => {
const [isValid, setIsValid] = useState(false);
const formRef = useRef<HTMLFormElement | null>(null);

useEffect(() => {
setIsValid(formRef.current?.checkValidity() ?? false);
}, [fields]);

useEffect(() => {
if (queryStatus === 'success' && blog) {
setFields(blog);
Expand All @@ -36,7 +40,6 @@ export const UpdateBlogForm = memo<Props>(({ blogId }) => {

const handleChange: ChangeEventHandler<HTMLInputElement> = useCallback(({ currentTarget }) => {
setFields((fields) => ({ ...fields, [currentTarget.name]: currentTarget.value }));
setIsValid(formRef.current?.checkValidity() ?? false);
}, []);

const handleInputCheckboxChange: ChangeEventHandler<HTMLInputElement> = useCallback(
Expand Down
5 changes: 5 additions & 0 deletions components/UpdateBlogSection/updateBlogForm.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
display: flex;
margin-right: 0.75rem;
}

&:read-only {
background-color: var(--reddish-white);
border: 1px solid var(--reddish-white);
}
}

.submitButton {
Expand Down
1 change: 1 addition & 0 deletions global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
--gray-text: #757575;
--gray-dark-border: #999999;
--white: #ffffff;
--reddish-white: #faf9f8;
--black: #000000;
--black-lighter: #{lighten(#000000, 20%)};
--error-color: #f16262;
Expand Down

0 comments on commit bbf171c

Please sign in to comment.