Skip to content

Commit

Permalink
Skip focus handling when openWhenFieldValidationError is set and ther…
Browse files Browse the repository at this point in the history
…e is an error
  • Loading branch information
tujoworker committed Sep 1, 2024
1 parent b31ff64 commit 4070ad0
Show file tree
Hide file tree
Showing 5 changed files with 217 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,24 @@ export type AllProps = Props & SectionContainerProps & FlexContainerProps
function EditContainer(props: AllProps) {
const { children, className, title, ...restProps } = props || {}
const ariaLabel = useMemo(() => convertJsxToString(title), [title])
const { switchContainerMode, containerMode } =
const { switchContainerMode, initialContainerMode } =
useContext(SectionContainerContext) || {}

const onPathError = useCallback(
(path: Path, error: Error) => {
if (
containerMode === 'openWhenFieldValidationError' &&
initialContainerMode === 'openWhenFieldValidationError' &&
error instanceof Error
) {
switchContainerMode?.('edit')
}
},
[switchContainerMode, containerMode]
[switchContainerMode, initialContainerMode]
)

return (
<FieldBoundaryProvider
showErrors={containerMode === 'openWhenFieldValidationError'}
showErrors={initialContainerMode === 'openWhenFieldValidationError'}
onPathError={onPathError}
>
<SectionContainer
Expand Down
Loading

0 comments on commit 4070ad0

Please sign in to comment.