<!-- Add the related story/sub-task/bug number, like Resolves #123, or remove if NA --> **Related issue:** Resolves #43640 # Checklist for submitter - [x] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files) for more information. ## Testing - [x] QA'd all new/changed functionality manually I figured out that the RunScriptModal was being re-rendered without any user events or network calls after the 2s mark. At first I thought the parent (ScriptModalGroup.tsx) could have been the culprit since there's a lot going on there (lots of callback functions passed to multiple modals). It turns out that RunScriptModal is wrapped in React.memo to avoid re-rendering but since some of its props changed in the parent component, this caused it to re-render and close the Actions dropdown randomly. To detect which where the problematic props changing, I threw this code at the top of RunScriptModal.tsx: ```react const prev = useRef<any>({}); useEffect(() => { const current = { currentUser, hostTeamId, onClose, page, setPage, hostScriptResponse, isFetchingHostScripts, isLoadingHostScripts, isError, onClickViewScript, onClickRunDetails, onClickRun, isRunningScript, isHidden, }; const changed = Object.entries(current).filter( ([k, v]) => prev.current[k] !== v ); console.log( "RunScriptModal re-render. Changed props:", changed.map(([k]) => k) ); prev.current = current; }); ``` and the output was: ``` RunScriptModal re-render. Changed props: (2) ['onClickViewScript', 'onClickRunDetails'] ``` So I just wrapped those two in useCallback and that fixed the issue. https://github.com/user-attachments/assets/f6eae13e-2a60-4fda-9468-2952acdedd58 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Bug Fixes * Fixed the Actions dropdown in the Run script modal on the Host details page auto-closing after 2-3 seconds. <!-- review_stack_entry_start --> [](https://app.coderabbit.ai/change-stack/fleetdm/fleet/pull/45349) <!-- review_stack_entry_end --> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2 lines
135 B
Plaintext
2 lines
135 B
Plaintext
* Fixed an issue where the Actions dropdown in the Run script modal within the Host details page would automatically close after 2-3s.
|