mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-01-24 23:36:48 -06:00
Reposition the select dropdown when the browser is resized. #5206
This commit is contained in:
parent
e17c50d304
commit
dd25bb0fff
@ -42,6 +42,7 @@ import QueryThresholds from './QueryThresholds';
|
||||
import SelectThemes from './SelectThemes';
|
||||
import { showFileManager } from '../helpers/showFileManager';
|
||||
import { withColorPicker } from '../helpers/withColorPicker';
|
||||
import { useWindowSize } from '../custom_hooks';
|
||||
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
@ -843,6 +844,7 @@ export const InputSelect = forwardRef(({
|
||||
const [[finalOptions, isLoading], setFinalOptions] = useState([[], true]);
|
||||
const theme = useTheme();
|
||||
|
||||
useWindowSize();
|
||||
|
||||
/* React will always take options let as changed parameter. So,
|
||||
We cannot run the below effect with options dependency as it will keep on
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {useRef, useEffect, useState, useCallback} from 'react';
|
||||
import {useRef, useEffect, useState, useCallback, useLayoutEffect} from 'react';
|
||||
import moment from 'moment';
|
||||
|
||||
/* React hook for setInterval */
|
||||
@ -181,3 +181,16 @@ export function useKeyboardShortcuts(shortcuts, eleRef) {
|
||||
shortcutsRef.current = shortcuts;
|
||||
}, [shortcuts]);
|
||||
}
|
||||
|
||||
export function useWindowSize() {
|
||||
const [size, setSize] = useState([999999, 999999]);
|
||||
useLayoutEffect(() => {
|
||||
function updateSize() {
|
||||
setSize([window.innerWidth, window.innerHeight]);
|
||||
}
|
||||
window.addEventListener('resize', updateSize);
|
||||
updateSize();
|
||||
return () => window.removeEventListener('resize', updateSize);
|
||||
}, []);
|
||||
return size;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user