Skip to content

Commit

Permalink
fix UI not updating properly error
Browse files Browse the repository at this point in the history
  • Loading branch information
EshaanAgg committed Jun 19, 2024
1 parent d09d570 commit 72b6576
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 16 deletions.
2 changes: 1 addition & 1 deletion benchexec/tablegenerator/react-table/build/main.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion benchexec/tablegenerator/react-table/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>React App</title>
<title>BenchExec</title>
<style>
#msg-container {
text-align: center;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { useLocation } from "react-router-dom";
*/
const NavSync = (props) => {
const location = useLocation();

useMemo(() => {
props.updateState();
props.updateFiltersFromUrl();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ export default class Overview extends React.Component {
clearImmediate(this.lastImmediate);
}
this.lastImmediate = setImmediate(() => {
this.filterUrlSetter(filter, window.history);
this.filterUrlSetter(filter);
this.lastFiltered = filter.filter(
(item) => (item.values && item.values.length > 0) || item.value,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default class SelectColumn extends React.Component {
hiddenParams["hidden"] = null;
}

setURLParameter(hiddenParams, window.history);
setURLParameter(hiddenParams);
}

// -------------------------Rendering-------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@ files
});

describe("Direct Plot should match HTML snapshot", () => {
console.log(window.location.href);
updateURLParams({ plot: plotInstance.plotOptions.direct });
console.log(window.location.href);

it.each(selectionResultInput)(
"with selection of the type %s and %s results",
Expand Down
16 changes: 6 additions & 10 deletions benchexec/tablegenerator/react-table/src/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,19 +267,15 @@ export const constructHashURL = (url, params = {}) => {
};

/**
* Sets or updates the search parameters in the URL hash of the current page. All the existing search parameters will not be disturbed. Also accepts a history object to update the URL hash without reloading the page.
* Sets or updates the search parameters in the URL hash of the current page. All the existing search parameters will not be disturbed.
* It can also be used to remove a parameter from the URL by setting it's value to undefined.
*
* @param {Object} params - The parameters to be set or updated in the URL hash
* @param {Object} [history=undefined] - The history object to update the URL hash without reloading the page
* @returns {void}
*/
const setURLParameter = (params = {}, history = undefined) => {
const { newUrl } = constructHashURL(window.location.href, params);
if (history && history.pushState) {
history.pushState({}, "", newUrl);
return;
}
window.history.pushState({}, "", newUrl);
window.location.href = newUrl;
};

Expand Down Expand Up @@ -701,17 +697,17 @@ const makeFilterDeserializer =

const makeUrlFilterSerializer = (statusValues, categoryValues) => {
const serializer = makeFilterSerializer({ statusValues, categoryValues });
return (filter, history) => {
return (filter) => {
if (!filter) {
return setURLParameter({ filter: undefined }, history);
return setURLParameter({ filter: undefined });
}

const encoded = serializer(filter);
if (encoded) {
return setURLParameter({ filter: encoded }, history);
return setURLParameter({ filter: encoded });
}

return setURLParameter({ filter: undefined }, history);
return setURLParameter({ filter: undefined });
};
};

Expand Down

0 comments on commit 72b6576

Please sign in to comment.