Skip to content

Commit c416549

Browse files
fix(notebook): fix run button disable/enable (#4422)
1 parent 8e89d18 commit c416549

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/flows/components/header/Submit.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const Submit: FC = () => {
1919
const {cancel} = useContext(QueryContext)
2020
const {generateMap, queryAll, status} = useContext(FlowQueryContext)
2121

22-
const hasQueries = generateMap().filter(s => !!s.source).length > 0
22+
const hasQueries = generateMap(true).filter(s => !!s.source).length > 0
2323

2424
const handleSubmit = () => {
2525
event('Notebook Submit Button Clicked')

src/flows/context/flow.query.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export interface Stage {
2525
}
2626

2727
export interface FlowQueryContextType {
28-
generateMap: () => Stage[]
28+
generateMap: (doubleForceUpdate?: boolean) => Stage[]
2929
printMap: (id?: string) => void
3030
query: (text: string, override?: QueryScope) => Promise<FluxResult>
3131
basic: (text: string, override?: QueryScope) => any
@@ -177,15 +177,16 @@ export const FlowQueryProvider: FC = ({children}) => {
177177
_generateMap()
178178
}, [flow])
179179

180-
const generateMap = (): Stage[] => {
180+
const generateMap = (doubleForceUpdate?: boolean): Stage[] => {
181181
// this is to get around an issue where a panel is added, which triggers the useEffect that updates
182182
// _map.current and a rerender that updates the panel view components within the same render cycle
183183
// leading to a panel on the list without a corresponding map entry
184184
const forceUpdate =
185185
(flow?.data?.allIDs ?? []).join(' ') !==
186186
(_map.current ?? []).map(m => m.id).join(' ')
187187

188-
if (forceUpdate) {
188+
if (forceUpdate || doubleForceUpdate) {
189+
// doubleForceUpdate is used to resolve react life cycle issue
189190
_generateMap()
190191
}
191192

0 commit comments

Comments
 (0)