⬆️ Migration to Mantine v5.0 in Popover

This commit is contained in:
ajnart
2022-08-07 17:20:34 +02:00
parent 03dd4b33ac
commit 68d1068059

View File

@@ -1,7 +1,7 @@
import { Kbd, createStyles, Autocomplete } from '@mantine/core'; import { Kbd, createStyles, Autocomplete, Popover, ScrollArea, Divider } from '@mantine/core';
import { useDebouncedValue, useHotkeys } from '@mantine/hooks'; import { useDebouncedValue, useHotkeys } from '@mantine/hooks';
import { useForm } from '@mantine/form'; import { useForm } from '@mantine/form';
import { useEffect, useRef, useState } from 'react'; import React, { useEffect, useRef, useState } from 'react';
import { import {
IconSearch as Search, IconSearch as Search,
IconBrandYoutube as BrandYoutube, IconBrandYoutube as BrandYoutube,
@@ -144,14 +144,16 @@ export default function SearchBar(props: any) {
<Popover <Popover
opened={OverseerrResults.length > 0 && opened} opened={OverseerrResults.length > 0 && opened}
position="bottom" position="bottom"
placement="start" withArrow
withinPortal
shadow="md"
radius="md" radius="md"
trapFocus={false} trapFocus
transition="pop-bottom-right" transition="pop-bottom-right"
onFocusCapture={() => setOpened(true)} >
onBlurCapture={() => setOpened(false)} <Popover.Target>
target={
<Autocomplete <Autocomplete
onFocusCapture={() => setOpened(true)}
autoFocus autoFocus
variant="filled" variant="filled"
data={autocompleteData} data={autocompleteData}
@@ -172,8 +174,9 @@ export default function SearchBar(props: any) {
{...props} {...props}
{...form.getInputProps('query')} {...form.getInputProps('query')}
/> />
} </Popover.Target>
>
<Popover.Dropdown onBlurCapture={() => setOpened(false)}>
<ScrollArea style={{ height: 400 }} offsetScrollbars> <ScrollArea style={{ height: 400 }} offsetScrollbars>
{OverseerrResults.slice(0, 5).map((result, index) => ( {OverseerrResults.slice(0, 5).map((result, index) => (
<React.Fragment key={index}> <React.Fragment key={index}>
@@ -182,6 +185,7 @@ export default function SearchBar(props: any) {
</React.Fragment> </React.Fragment>
))} ))}
</ScrollArea> </ScrollArea>
</Popover.Dropdown>
</Popover> </Popover>
</form> </form>
); );