Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Rework ModalManager to use <dialog> #8847

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 21 additions & 37 deletions res/css/_common.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -278,22 +278,32 @@ legend {
*/

.mx_Dialog_wrapper {
position: fixed;
z-index: 4000;
top: 0;
position: absolute;
left: 0;
width: 100%;
height: 100%;
right: 0;
width: fit-content;
height: fit-content;
margin: auto;

display: flex;
align-items: center;
justify-content: center;
// override browser default decorations
border: none;
background: unset;

&::backdrop {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;

background-color: $dialog-backdrop-color;
opacity: 0.8;
}
}

.mx_Dialog {
background-color: $background;
color: $light-fg-color;
z-index: 4012;
font-size: $font-15px;
position: relative;
padding: 24px;
Expand Down Expand Up @@ -375,33 +385,7 @@ legend {
max-width: 704px;
}

.mx_Dialog_staticWrapper .mx_Dialog {
z-index: 4010;
contain: content;
}

.mx_Dialog_background {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: $dialog-backdrop-color;
opacity: 0.8;
z-index: 4011;
}

.mx_Dialog_background.mx_Dialog_staticBackground {
z-index: 4009;
}

.mx_Dialog_wrapperWithStaticUnder .mx_Dialog_background {
/* Roughly half of what it would normally be - we don't want to black out */
/* the app, just make it clear that the dialogs are stacked. */
opacity: 0.4;
}

.mx_Dialog_lightbox .mx_Dialog_background {
.mx_Dialog_lightbox {
opacity: $lightbox-background-bg-opacity;
background-color: $lightbox-background-bg-color;
animation-name: mx_Dialog_lightbox_background_keyframes;
Expand Down Expand Up @@ -585,7 +569,7 @@ legend {
}

/* Spinner Dialog overide */
.mx_Dialog_wrapper.mx_Dialog_spinner .mx_Dialog {
.mx_Dialog_spinner .mx_Dialog {
width: auto;
border-radius: 8px;
padding: 8px;
Expand Down
1 change: 0 additions & 1 deletion res/css/components/views/beacon/_BeaconViewDialog.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ limitations under the License.
}

.mx_Dialog_cancelButton {
z-index: 4010;
position: fixed;
right: 5vw;
top: 5vh;
Expand Down
12 changes: 6 additions & 6 deletions res/css/views/dialogs/_CompoundDialog.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ limitations under the License.
/* be in their respective stylesheets. */
/* -------------------------------------------------------------------------------- */

/* Override legacy/default styles for dialogs */
.mx_Dialog_wrapper.mx_CompoundDialog > .mx_Dialog {
padding: 0; /* we'll manage it ourselves */
color: $primary-content;
}

.mx_CompoundDialog {
/* Override legacy/default styles for dialogs */
> .mx_Dialog {
padding: 0; /* we'll manage it ourselves */
color: $primary-content;
}

.mx_CompoundDialog_header {
padding: 32px 32px 16px 32px;

Expand Down
1 change: 0 additions & 1 deletion res/css/views/dialogs/_LocationViewDialog.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ limitations under the License.
}

.mx_Dialog_cancelButton {
z-index: 4010;
position: absolute;
right: 5vw;
top: 5vh;
Expand Down
6 changes: 5 additions & 1 deletion res/css/views/dialogs/_SpotlightDialog.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

.mx_SpotlightDialog_wrapper {
overflow: visible;
}

.mx_SpotlightDialog_wrapper .mx_Dialog {
border-radius: 8px;
overflow-y: initial;
position: relative;
height: 60%;
height: 60vh;
padding: 0;
contain: unset; /* needed for #mx_SpotlightDialog_keyboardPrompt to not be culled */

Expand Down
4 changes: 4 additions & 0 deletions src/@types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ declare global {
setSinkId(outputId: string): void;
}

interface HTMLDialogElement {
oncancel?(ev: Event);
}

// Add Chrome-specific `instant` ScrollBehaviour
type _ScrollBehavior = ScrollBehavior | "instant";

Expand Down
3 changes: 2 additions & 1 deletion src/AsyncWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ export default class AsyncWrapper extends React.Component<IProps, IState> {
} else if (this.state.error) {
return <BaseDialog onFinished={this.props.onFinished} title={_t("Error")}>
{ _t("Unable to load! Check your network connectivity and try again.") }
<DialogButtons primaryButton={_t("Dismiss")}
<DialogButtons
primaryButton={_t("Dismiss")}
onPrimaryButtonClick={this.onWrapperCancelClick}
hasCancel={false}
/>
Expand Down
Loading