fix: stop caching popup

This commit is contained in:
Shusui MOYATANI
2024-01-10 21:00:59 +09:00
parent b491d4f537
commit 94ec3a0924
2 changed files with 6 additions and 14 deletions

View File

@@ -1,4 +1,4 @@
import { createMemo, children } from 'solid-js'; import { createMemo } from 'solid-js';
import { Picker } from 'emoji-mart'; import { Picker } from 'emoji-mart';
@@ -28,7 +28,7 @@ const useEmojiPicker = (propsProvider: () => UseEmojiPickerProps) => {
let popup: UsePopup | undefined; let popup: UsePopup | undefined;
const pickerElement = children(() => { const pickerElement = () => {
const customEmojis = Object.entries(config().customEmojis).map(([name, { url }]) => ({ const customEmojis = Object.entries(config().customEmojis).map(([name, { url }]) => ({
id: name, id: name,
name, name,
@@ -66,7 +66,7 @@ const useEmojiPicker = (propsProvider: () => UseEmojiPickerProps) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
return picker as any as HTMLElement; return picker as any as HTMLElement;
}); };
popup = usePopup(() => ({ popup = usePopup(() => ({
position: 'bottom', position: 'bottom',

View File

@@ -1,12 +1,4 @@
import { import { createSignal, createEffect, createMemo, onCleanup, Show, type JSX } from 'solid-js';
createSignal,
createEffect,
createMemo,
onCleanup,
children,
Show,
type JSX,
} from 'solid-js';
import { Portal } from 'solid-js/web'; import { Portal } from 'solid-js/web';
@@ -31,13 +23,13 @@ const usePopup = (propsProvider: () => UsePopupProps): UsePopup => {
const [style, setStyle] = createSignal<JSX.CSSProperties>({}); const [style, setStyle] = createSignal<JSX.CSSProperties>({});
const [isOpen, setIsOpen] = createSignal(false); const [isOpen, setIsOpen] = createSignal(false);
const resolvedChildren = children(() => { const resolvedChildren = () => {
const { popup } = props(); const { popup } = props();
if (typeof popup === 'function') { if (typeof popup === 'function') {
return popup(); return popup();
} }
return popup; return popup;
}); };
const open = () => setIsOpen(true); const open = () => setIsOpen(true);
const close = () => setIsOpen(false); const close = () => setIsOpen(false);