From 0768bac73b7c2ae771ac5c7e3236390d000bca12 Mon Sep 17 00:00:00 2001 From: manasa Date: Tue, 24 Feb 2026 19:25:17 +0530 Subject: [PATCH 1/3] Fixed the Refresh call issue for RDL issue --- .../src/hooks/useFocusFirstField.ts | 35 +++++++++++++++---- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/packages/react-sdk-components/src/hooks/useFocusFirstField.ts b/packages/react-sdk-components/src/hooks/useFocusFirstField.ts index 2012f12c..cd914ae6 100644 --- a/packages/react-sdk-components/src/hooks/useFocusFirstField.ts +++ b/packages/react-sdk-components/src/hooks/useFocusFirstField.ts @@ -1,22 +1,43 @@ -import { useEffect } from 'react'; +import { useEffect, useRef } from 'react'; /** * @example useFocusFirstField(id, children); - * Focuses first editable field in the view. + * Focuses first editable field in the view based on field identity. */ const useFocusFirstField = (id, children) => { + // Track the unique identity (id or name) of the first field we focused + const lastFirstFieldIdentifier = useRef(null); + useEffect(() => { const assignment = document.getElementById(id); + if (assignment) { - // Find all editable elements within the div - const editableElements: NodeListOf = assignment.querySelectorAll('input, select, textarea'); + const editableElements = assignment.querySelectorAll('input:not([disabled]), select:not([disabled]), textarea:not([disabled])'); - // Focus on the first editable element if (editableElements.length > 0) { - editableElements[0].focus(); + const firstElement: any = editableElements[0]; + + const currentIdentifier = firstElement.id || firstElement.name || firstElement; + + // If the first field's identity has changed, it means we navigated to a new view + if (lastFirstFieldIdentifier.current !== currentIdentifier) { + // Use setTimeout to defer focus slightly. + // This ensures that after a "Submit" click, React has fully committed the + // new DOM and the browser's native click events have finished resolving. + setTimeout(() => { + firstElement.focus(); + }, 0); + + // Update the ref. Now, if the user adds/edits a record in THIS view, + // the identifier will match, and the hook will safely do nothing. + lastFirstFieldIdentifier.current = currentIdentifier; + } + } else { + // If the new view is read-only (no inputs found), reset the tracker + lastFirstFieldIdentifier.current = null; } } - }, [children]); + }, [id, children]); }; export default useFocusFirstField; From f605db34eda1161d63f9315f68e4ee75704137c8 Mon Sep 17 00:00:00 2001 From: manasa Date: Tue, 24 Feb 2026 19:52:48 +0530 Subject: [PATCH 2/3] updated as per comments --- .../src/hooks/useFocusFirstField.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/react-sdk-components/src/hooks/useFocusFirstField.ts b/packages/react-sdk-components/src/hooks/useFocusFirstField.ts index cd914ae6..3e95a558 100644 --- a/packages/react-sdk-components/src/hooks/useFocusFirstField.ts +++ b/packages/react-sdk-components/src/hooks/useFocusFirstField.ts @@ -6,7 +6,7 @@ import { useEffect, useRef } from 'react'; */ const useFocusFirstField = (id, children) => { // Track the unique identity (id or name) of the first field we focused - const lastFirstFieldIdentifier = useRef(null); + const prevFirstFieldId = useRef(null); useEffect(() => { const assignment = document.getElementById(id); @@ -20,7 +20,7 @@ const useFocusFirstField = (id, children) => { const currentIdentifier = firstElement.id || firstElement.name || firstElement; // If the first field's identity has changed, it means we navigated to a new view - if (lastFirstFieldIdentifier.current !== currentIdentifier) { + if (prevFirstFieldId.current !== currentIdentifier) { // Use setTimeout to defer focus slightly. // This ensures that after a "Submit" click, React has fully committed the // new DOM and the browser's native click events have finished resolving. @@ -28,13 +28,13 @@ const useFocusFirstField = (id, children) => { firstElement.focus(); }, 0); - // Update the ref. Now, if the user adds/edits a record in THIS view, + // Update the ref. Now, if the user adds/edits a record in this view, // the identifier will match, and the hook will safely do nothing. - lastFirstFieldIdentifier.current = currentIdentifier; + prevFirstFieldId.current = currentIdentifier; } } else { // If the new view is read-only (no inputs found), reset the tracker - lastFirstFieldIdentifier.current = null; + prevFirstFieldId.current = null; } } }, [id, children]); From a50678c3a59230fa9b6e4eb0d4eedd75c5d3b9b0 Mon Sep 17 00:00:00 2001 From: Siva Rama Krishna Date: Tue, 24 Feb 2026 22:37:57 +0530 Subject: [PATCH 3/3] fix: improve useFocusFirstField hook --- .../FieldGroupList/FieldGroupList.tsx | 2 +- .../infra/Assignment/Assignment.tsx | 3 +- .../src/hooks/useFocusFirstField.ts | 48 +++++++------------ 3 files changed, 21 insertions(+), 32 deletions(-) diff --git a/packages/react-sdk-components/src/components/designSystemExtension/FieldGroupList/FieldGroupList.tsx b/packages/react-sdk-components/src/components/designSystemExtension/FieldGroupList/FieldGroupList.tsx index f6ee02cb..42fecaa3 100644 --- a/packages/react-sdk-components/src/components/designSystemExtension/FieldGroupList/FieldGroupList.tsx +++ b/packages/react-sdk-components/src/components/designSystemExtension/FieldGroupList/FieldGroupList.tsx @@ -24,7 +24,7 @@ export default function FieldGroupList(props: FieldGroupListProps) { {props.items.map(item => ( - + {item.name} {props.onDelete && (