Skip to content

Commit

Permalink
Fix broken translate view when filters result in no matches (#3054)
Browse files Browse the repository at this point in the history
Always use Hooks at the top level of your React function:
https://legacy.reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
  • Loading branch information
mathjazz authored Dec 18, 2023
1 parent 2cea74d commit 0aeaa3e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions translate/src/modules/entitieslist/components/EntitiesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ export function EntitiesList(): React.ReactElement<'div'> {
const mounted = useRef(false);
const list = useRef<HTMLDivElement>(null);

const selectedEntitiesCount = batchactions.entities.length;
const windowWidth = useWindowWidth();
const entitiesList = useContext(EntitiesListContext);
const quitBatchActions = useCallback(() => dispatch(resetSelection()), []);
const showBatchActions = useCallback(() => entitiesList.show(false), []);

useEffect(() => {
const handleShortcuts = (ev: KeyboardEvent) => {
// On Ctrl + Shift + A, select all entities for batch editing.
Expand Down Expand Up @@ -272,12 +278,6 @@ export function EntitiesList(): React.ReactElement<'div'> {
);
}

const selectedEntitiesCount = batchactions.entities.length;
const windowWidth = useWindowWidth();
const entitiesList = useContext(EntitiesListContext);
const quitBatchActions = useCallback(() => dispatch(resetSelection()), []);
const showBatchActions = useCallback(() => entitiesList.show(false), []);

return (
<div className='entities unselectable' ref={list}>
<ul>
Expand Down

0 comments on commit 0aeaa3e

Please sign in to comment.