Skip to content

Commit ac268e9

Browse files
Show an overlay when native dialogs are up (#608)
I tried using before/afterrequestdevice events but it was more involved and had gaps in the radio bridge flow with no overlay. Bluetooth is already fine as a "connecting" dialog is shown in the background.
1 parent 093dd09 commit ac268e9

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* (c) 2025, Micro:bit Educational Foundation and contributors
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*/
6+
import { Box } from "@chakra-ui/react";
7+
import { useIntl } from "react-intl";
8+
9+
const ChooseDeviceOverlay = () => {
10+
const intl = useIntl();
11+
return (
12+
<Box
13+
// We don't really expect it to be possible to interact with this overlay
14+
// as it is only shown when the native browser requestDeviceDialog is
15+
// open. But still useful for code trying to identify open dialogs.
16+
role="dialog"
17+
aria-label={intl.formatMessage({ id: "connect-popup-instruction1" })}
18+
width="100vw"
19+
height="100vh"
20+
background="blackAlpha.600"
21+
position="fixed"
22+
top={0}
23+
left={0}
24+
zIndex="overlay"
25+
/>
26+
);
27+
};
28+
29+
export default ChooseDeviceOverlay;

src/components/ConnectionFlowDialogs.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import TryAgainDialog from "./TryAgainDialog";
3232
import UnsupportedMicrobitDialog from "./UnsupportedMicrobitDialog";
3333
import WebUsbBluetoothUnsupportedDialog from "./WebUsbBluetoothUnsupportedDialog";
3434
import WhatYouWillNeedDialog from "./WhatYouWillNeedDialog";
35+
import ChooseDeviceOverlay from "./ChooseDeviceOverlay";
3536

3637
const ConnectionDialogs = () => {
3738
const { stage, actions } = useConnectionStage();
@@ -174,7 +175,7 @@ const ConnectionDialogs = () => {
174175
}
175176
case ConnectionFlowStep.WebUsbChooseMicrobit: {
176177
// Browser dialog is shown, no custom dialog shown at the same time
177-
return <></>;
178+
return <ChooseDeviceOverlay />;
178179
}
179180
case ConnectionFlowStep.FlashingInProgress: {
180181
return (

0 commit comments

Comments
 (0)