Add historyCurrentStep to setHistory event
This commit is contained in:
parent
749609f9a0
commit
7a81bbaec6
3 changed files with 14 additions and 10 deletions
|
@ -158,7 +158,7 @@ function UseCustomEvents(
|
|||
historyCurrentStep: number,
|
||||
configuration: IConfiguration,
|
||||
editorRef: React.RefObject<HTMLDivElement>,
|
||||
setNewHistory: (newHistory: IHistoryState[]) => void
|
||||
setNewHistory: (newHistory: IHistoryState[], historyCurrentStep?: number) => void
|
||||
): void {
|
||||
useEffect(() => {
|
||||
const editorState: IEditorState = {
|
||||
|
@ -219,10 +219,10 @@ function UseEditorListener(
|
|||
function UseNewHistoryState(
|
||||
setHistory: Dispatch<SetStateAction<IHistoryState[]>>,
|
||||
setHistoryCurrentStep: Dispatch<SetStateAction<number>>
|
||||
): (newHistory: IHistoryState[]) => void {
|
||||
return (newHistory) => {
|
||||
): (newHistory: IHistoryState[], historyCurrentStep?: number) => void {
|
||||
return (newHistory, historyCurrentStep?: number) => {
|
||||
setHistory(newHistory);
|
||||
setHistoryCurrentStep(newHistory.length - 1);
|
||||
setHistoryCurrentStep(historyCurrentStep !== undefined && historyCurrentStep !== null ? historyCurrentStep : newHistory.length - 1);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue