Skip to content

Commit

Permalink
fix: user rejection bug
Browse files Browse the repository at this point in the history
  • Loading branch information
chakra-guy committed Jan 20, 2025
1 parent 123dd05 commit 7f18042
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions packages/sdk-install-modal-web/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export interface MmSelectModalCustomEvent<T> extends CustomEvent<T> {
}
declare global {
interface HTMLMmInstallModalElementEventMap {
"close": any;
"close": { shouldTerminate?: boolean };
"startDesktopOnboarding": any;
"trackAnalytics": { event: TrackingEvents, params?: Record<string, unknown> };
}
Expand Down Expand Up @@ -114,7 +114,7 @@ declare namespace LocalJSX {
* The QR code link
*/
"link"?: string;
"onClose"?: (event: MmInstallModalCustomEvent<any>) => void;
"onClose"?: (event: MmInstallModalCustomEvent<{ shouldTerminate?: boolean }>) => void;
"onStartDesktopOnboarding"?: (event: MmInstallModalCustomEvent<any>) => void;
"onTrackAnalytics"?: (event: MmInstallModalCustomEvent<{ event: TrackingEvents, params?: Record<string, unknown> }>) => void;
"preferDesktop"?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class InstallModal {

private i18nInstance: SimpleI18n;

@Event() close: EventEmitter;
@Event() close: EventEmitter<{ shouldTerminate?: boolean }>;

@Event() startDesktopOnboarding: EventEmitter;

Expand Down Expand Up @@ -79,8 +79,8 @@ export class InstallModal {
}
}

onClose() {
this.close.emit();
onClose(shouldTerminate = false) {
this.close.emit({ shouldTerminate });
}

onStartDesktopOnboardingHandler() {
Expand Down Expand Up @@ -123,11 +123,11 @@ export class InstallModal {

return (
<WidgetWrapper className="install-model">
<div class='backdrop' onClick={() => this.onClose()}></div>
<div class='backdrop' onClick={() => this.onClose(true)}></div>
<div class='modal'>
<div class='closeButtonContainer'>
<div class='right'>
<span class='closeButton' onClick={() => this.onClose()}>
<span class='closeButton' onClick={() => this.onClose(true)}>
<CloseButton />
</span>
</div>
Expand Down
7 changes: 5 additions & 2 deletions packages/sdk/src/ui/InstallModal/Modal-web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { Components } from '@metamask/sdk-install-modal-web';

export interface InstallWidgetProps extends Components.MmInstallModal {
parentElement: Element;
onClose: () => void;
onClose: (shouldTerminate?: boolean) => void;
metaMaskInstaller: {
startDesktopOnboarding: () => void;
};
Expand Down Expand Up @@ -80,7 +80,10 @@ export default class ModalLoader {
modal.link = props.link;
modal.preferDesktop = props.preferDesktop;
modal.sdkVersion = props.sdkVersion ?? this.sdkVersion;
modal.addEventListener('close', props.onClose);
modal.addEventListener('close', ({ detail: { shouldTerminate } }) =>
props.onClose(shouldTerminate),
);

modal.addEventListener(
'startDesktopOnboarding',
props.metaMaskInstaller.startDesktopOnboarding,
Expand Down

0 comments on commit 7f18042

Please sign in to comment.