From a33aebca382b14340442038061f5ed678a01074f Mon Sep 17 00:00:00 2001 From: Thomas Parisot Date: Tue, 21 Jan 2025 18:00:08 +0100 Subject: [PATCH 1/2] =?UTF-8?q?fix(Field):=20restaure=20le=20focus=20manue?= =?UTF-8?q?l=20plut=C3=B4t=20que=20d'utiliser=20l'attribut=20autoFocus=20d?= =?UTF-8?q?e=20React?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/src/components/Field.jsx | 37 ++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/front/src/components/Field.jsx b/front/src/components/Field.jsx index 9790f5eaf..b0c526479 100644 --- a/front/src/components/Field.jsx +++ b/front/src/components/Field.jsx @@ -1,28 +1,39 @@ import clsx from 'clsx' -import React, { forwardRef } from 'react' +import React, { forwardRef, useEffect, useRef } from 'react' import styles from './field.module.scss' export default forwardRef(function Field( - { hasError, className, prefix, children, label, id, type, ...otherProps }, + { + hasError, + className, + prefix, + children, + label, + id, + type, + autoFocus = false, + ...otherProps + }, forwardedRef ) { - const classNames = [ + const inputRef = forwardedRef ?? useRef() + const classNames = clsx( styles.field, prefix && styles.withPrefix, 'control-field', - ] - - if (className) { - classNames.push(className) - } - if (hasError) { - classNames.push(styles.error) - } + className && className, + hasError && styles.error + ) const computedStyles = { '--chars-count': prefix?.length } + useEffect(() => { + if (autoFocus) { + inputRef.current.focus() + } + }, []) return ( -
+
{label && }
{otherProps.icon && ( From 2964f104086613fc6c70ff77bc892bca04dcf383 Mon Sep 17 00:00:00 2001 From: Thomas Parisot Date: Tue, 21 Jan 2025 18:00:35 +0100 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20d=C3=A9clenche=20l'autofocus=20pour?= =?UTF-8?q?=20le=20premier=20champ=20des=20modales=20de=20cr=C3=A9ation=20?= =?UTF-8?q?de=20tag/workspace?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/src/components/TagCreate.jsx | 1 + front/src/components/workspace/CreateWorkspace.jsx | 1 + 2 files changed, 2 insertions(+) diff --git a/front/src/components/TagCreate.jsx b/front/src/components/TagCreate.jsx index 79b35cf03..73bec1386 100644 --- a/front/src/components/TagCreate.jsx +++ b/front/src/components/TagCreate.jsx @@ -61,6 +61,7 @@ export default function TagCreate() {