Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Focus approval request UI when a request is queued #4456

Merged
merged 5 commits into from
Jun 24, 2024

Conversation

jiexi
Copy link
Contributor

@jiexi jiexi commented Jun 24, 2024

Explanation

Currently when a request is queued, it does not cause the existing confirmation window to be focused. This is because queued requests are withheld from the ApprovalController which is responsible for showing batched/scrubbable confirmations to the user. Since the ApprovalController never actually receives queued requests until they are ready to be shown to the user, it becomes the responsibility of the QueuedRequestController to determine when the confirmation window must be focused because a new confirmation has been enqueued.

This PR adds a new callback/hook to the QueuedRequestController, enabling it to trigger the notification window receiving focus.

References

Fixes: MetaMask/metamask-extension#25397

Changelog

@metamask/queued-request-controller

  • BREAKING: QueuedRequestController constructor params now requires a showApprovalRequest hook that is called when the approval request UI should be opened/focused as the result of a request with confirmation being enqueued.

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've highlighted breaking changes using the "BREAKING" category above as appropriate

@@ -83,6 +83,7 @@ export type QueuedRequestControllerOptions = {
request: QueuedRequestMiddlewareJsonRpcRequest,
) => boolean;
clearPendingConfirmations: () => void;
showApprovalRequest: () => void;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be optional?..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably not? this controller will only be used on the extension AFAIK and I believe we will always want this hook passed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's optional in the sense that this isn't required for the QueuedRequestController to perform it's core function

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure thats definitely true. I guess I think of the type as safeguard for accidental removal... though maybe that's not really true

@jiexi jiexi marked this pull request as ready for review June 24, 2024 20:42
@jiexi jiexi requested a review from a team as a code owner June 24, 2024 20:42
Copy link
Contributor

@adonesky1 adonesky1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@jiexi jiexi merged commit 9b2b7bc into main Jun 24, 2024
117 checks passed
@jiexi jiexi deleted the jl/add-showApprovalRequest-QueuedRequestController branch June 24, 2024 21:01
@jiexi jiexi mentioned this pull request Jun 24, 2024
jiexi added a commit that referenced this pull request Jun 24, 2024
Releases `queued-request-controller`
#4456
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Bring popup to the foreground functionality is not working as expected.
2 participants