-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55494 from huult/53814-fix-confirmation-button-jump
53814 fix confirmation button jump
- Loading branch information
Showing
4 changed files
with
84 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React, {useContext, useMemo, useState} from 'react'; | ||
import type ChildrenProps from '@src/types/utils/ChildrenProps'; | ||
|
||
type InputBlurContextType = { | ||
isBlurred: boolean; // Boolean state to track blur | ||
setIsBlurred: React.Dispatch<React.SetStateAction<boolean>>; // Function to update the state | ||
}; | ||
|
||
const InputBlurContext = React.createContext<InputBlurContextType>({ | ||
isBlurred: true, | ||
setIsBlurred: () => {}, | ||
}); | ||
|
||
function InputBlurContextProvider({children}: ChildrenProps) { | ||
const [isBlurred, setIsBlurred] = useState<boolean>(false); | ||
|
||
const contextValue = useMemo( | ||
() => ({ | ||
isBlurred, | ||
setIsBlurred, | ||
}), | ||
[isBlurred], | ||
); | ||
|
||
return <InputBlurContext.Provider value={contextValue}>{children}</InputBlurContext.Provider>; | ||
} | ||
|
||
function useInputBlurContext() { | ||
return useContext(InputBlurContext); | ||
} | ||
|
||
export {InputBlurContext, useInputBlurContext, InputBlurContextProvider}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters