Skip to content

Commit 8733b26

Browse files
authored
feat: fix Install Plugin button in extension menu
#131
1 parent 846bc1e commit 8733b26

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/components/Menu/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export default function Menu(props: {
6060
props.setOpen(false);
6161
}}
6262
>
63-
<PluginUploadInfo />
63+
<PluginUploadInfo onPluginInstalled={() => props.setOpen(false)} />
6464
<span>Install Plugin</span>
6565
</MenuRow>
6666
<MenuRow

src/components/PluginInfo/index.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ import { ErrorModal } from '../ErrorModal';
2626
import classNames from 'classnames';
2727
import DefaultPluginIcon from '../../assets/img/default-plugin-icon.png';
2828

29-
export default function PluginUploadInfo(): ReactElement {
29+
export default function PluginUploadInfo({
30+
onPluginInstalled,
31+
}: {
32+
onPluginInstalled?: () => void;
33+
}): ReactElement {
3034
const [error, showError] = useState('');
3135
const [pluginBuffer, setPluginBuffer] = useState<ArrayBuffer | any>(null);
3236
const [pluginContent, setPluginContent] = useState<PluginConfig | null>(null);
@@ -36,6 +40,7 @@ export default function PluginUploadInfo(): ReactElement {
3640
try {
3741
await addPlugin(Buffer.from(pluginBuffer).toString('hex'));
3842
setPluginContent(null);
43+
onPluginInstalled?.();
3944
} catch (e: any) {
4045
showError(e?.message || 'Invalid Plugin');
4146
}
@@ -72,6 +77,9 @@ export default function PluginUploadInfo(): ReactElement {
7277
className="opacity-0 absolute top-0 right-0 h-full w-full cursor-pointer"
7378
type="file"
7479
onChange={onPluginInfo}
80+
onClick={(e) => {
81+
e.stopPropagation();
82+
}}
7583
/>
7684
{error && <ErrorModal onClose={() => showError('')} message={error} />}
7785
{pluginContent && (

0 commit comments

Comments
 (0)