Skip to content

Commit

Permalink
fix: set max width for search options
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonella Sgarlatta committed Jun 24, 2021
1 parent d8a148c commit a61f43c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/assets/javascripts/components/SearchOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const SearchOptions = observer(({ appState }: Props) => {
top: 0,
right: 0,
});
const [maxWidth, setMaxWidth] = useState<number | 'auto'>('auto');
const buttonRef = useRef<HTMLButtonElement>();
const panelRef = useRef<HTMLDivElement>();
const [closeOnBlur, setLockCloseOnBlur] = useCloseOnBlur(panelRef, setOpen);
Expand All @@ -49,6 +50,7 @@ const SearchOptions = observer(({ appState }: Props) => {
open={open}
onChange={() => {
const rect = buttonRef.current.getBoundingClientRect();
setMaxWidth(rect.right - 16);
setPosition({
top: rect.bottom,
right: document.body.clientWidth - rect.right,
Expand All @@ -68,8 +70,9 @@ const SearchOptions = observer(({ appState }: Props) => {
ref={panelRef}
style={{
...position,
maxWidth,
}}
className="sn-dropdown sn-dropdown--animated min-w-80 fixed grid gap-2 py-2"
className="sn-dropdown sn-dropdown--animated w-80 fixed grid gap-2 py-2"
onBlur={closeOnBlur}
>
<Switch
Expand Down

0 comments on commit a61f43c

Please sign in to comment.