Skip to content

Commit

Permalink
test: add flushsync to fix uploader flaky tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mfanselmo authored and jgespinosa10 committed Aug 28, 2024
1 parent 672498d commit 0e42f3c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/ui/src/DataTable/ColumnFilterMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const ColumnFilterMenu = ({
<Icon
style={{ marginLeft: 5 }}
icon="filter"
iconSize={extraCompact ? 14 : undefined}
size={extraCompact ? 14 : undefined}
onClick={() => setColumnFilterMenuOpen(prev => !prev)}
className={classNames("tg-filter-menu-button", {
"tg-active-filter": !!filterActiveForColumn
Expand Down
13 changes: 8 additions & 5 deletions packages/ui/src/FormComponents/Uploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import classNames from "classnames";
import convertSchema from "../DataTable/utils/convertSchema";
import { LoadingDots } from "./LoadingDots";
import { useDispatch } from "react-redux";
import { flushSync } from "react-dom";

const manualEnterMessage = "Build CSV File";
const manualEnterSubMessage = "Paste or type data to build a CSV file";
Expand Down Expand Up @@ -249,11 +250,13 @@ const Uploader = ({
// onChange received from redux-form is not working anymore,
// so we need to overwrite it for redux to works.
const onChange = val => {
if (noRedux) {
return _onChange(val);
}
dispatch(touch(formName, name));
return dispatch(change(formName, name, val));
flushSync(() => {
if (noRedux) {
return _onChange(val);
}
dispatch(touch(formName, name));
dispatch(change(formName, name, val));
});
};

const handleSecondHalfOfUpload = async ({
Expand Down

0 comments on commit 0e42f3c

Please sign in to comment.