Angular Material: Enable Window Dragging Across Multiple Monitors

Exploring the usage of Angular Material Dialog or any other Popup Window Component. The functionality is mostly working as expected, with the exception of the last point.

a) The original screen should not have a grey overlay,

b) Users should be able to interact with the underlying first window,

c) Data should be sent back to the original window component,

d) There should be support for moving the modal/popup window to a second monitor screen with dual monitors. This feature is currently not functioning properly.

Ideally, it should behave like a standard popup window. How can this be achieved using Angular Material Dialog?

public openPropertySearchDialog(): void {
    const propertySearchDialogRef = this.openPropertySearchDialog.open(DocumentPropertyGridComponent, {
      width: '800px',
      height: '450px',
      disableClose: true,
      autoFocus: false,
      data: "test",
      hasBackdrop: false
    });

    propertySearchDialogRef.afterClosed().subscribe(result => {});
  }

While we could use javascript's window.open function, we prefer Angular Material due to its comprehensive data binding communication service. If there are other Angular options available, those would also be suitable solutions.

The basic flow involves a user clicking on Component 1: "Add Document", where the variable

selectedDocumentList: Array<string>
gets passed to Component 2:
cumulativeDocumentList: Array<string>
. The cumulative list should update in real-time, and we want to achieve this functionality using Angular Material Window Dialog.

(click picture to zoom in)
https://i.sstatic.net/dPrMc.png

Resource:

How can i make a MatDialog draggable / Angular Material

Answer №1

Material Dialog is more than just a window - it's an HTML element that appears in a fixed position on the screen. Even if you try to make it draggable, it will only stay within the current tab of your browser. Using window.open might be a better solution.

IDEA:

You could create a route with a component that contains the Material Dialog and automatically opens it using the AfterViewInit hook.

For example, https://localhost:8443/dialogs/1 would be the route, and when you want to open the dialog in a new window, you can use the following code:

  open() {
    const myWindow = window.open(
      'https://localhost:8443/dialogs/1',
      '_blank',
      'width=200, height=100'
    );
  }

From the popup window itself, you can interact with the parent window like this:

  onNoClick(data: string): void {
    this.dialogRef.close();
    console.log(window.opener);
    const parent = window.opener;
    // Is it possible to pass data to the parent window and trigger a change?
    // window.close();
  }

Learn more about exposing Angular 2 methods publicly here.

Answer №2

It's not just a matter of simply dragging the component off the screen; there are additional complexities involved. One workaround could involve adding a button to the modal you wish to drag, which would then open up another browser tab with the component that can be dragged outside the window onto a separate screen. However, this solution does come with its own set of challenges - the component may need to be routed, possibly using a different router-outlet in order to maintain a different layout.

Best of luck!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Angular 5 facing issue with loading external scripts dynamically

I have configured the external scripts in the .angular-cli.json file under the scripts property: ` "scripts": [ "../src/assets/plugins/jquery/jquery.min.js", "../src/assets/plugins/popper/popper.min.js", "../src/assets/plugins/jquer ...

Could I possibly incorporate @mui/material into an Angular project?

Is it possible to use npm install @mui/material in Angular? I am new to Angular and unsure if this will work. If not, are there any alternative Angular libraries that offer Material UI compatibility? ...

Discover the data type without using the extends keyword within an interface in Typescript

I'm struggling with making my code declarative enough. I want to infer a type inside an interface scope and then use that same type as an argument for a method within the interface. Here is a simple example: interface Prop { x: infer U, // ^^ ...

Error encountered: TypeScript module 'angularfire2/interfaces' not found in Ionic 3 with angularfire2-offline plugin

Encountering an error while trying to set up angularfire2-offline: [16:02:08] typescript: node_modules/angularfire2-offline/database/database.d.ts, line: 2 Cannot find module 'angularfire2/interfaces'. L1: import { Angula ...

Frequent occurrence when a variable is utilized prior to being assigned

I am currently working with a module import pino, { Logger } from 'pino'; let logger: Logger; if (process.env.NODE_ENV === 'production') { const dest = pino.extreme(); logger = pino(dest); } if (process.env.NODE_ENV === &apo ...

Challenge involving Angular for creating multiline innerHtml contentEditable feature

I am currently working on a project using Angular5 to create a unique type of "text-editor" utilizing div elements with the contenteditable property. This setup allows users to input plain text, but also enables them to select specific text and trigger an ...

Issue with hydration in Next.js while trying to access the persisted "token" variable in Zustand and triggering a loading spinner

Below is the code snippet from _app.tsx where components/pages are wrapped in a PageWrapper component that handles displaying a loading spinner. export default function App(props: MyAppProps) { const updateJWT = useJWTStore((state) => state.setJWT); ...

The young one emerges within the SecurePath component temporarily

Setting up authorization in React has been a priority for me. Ensuring that users cannot access unauthorized pages within the application is crucial. To achieve this, I have created a custom component as shown below. import { ReactNode } from "react&q ...

Tips for remembering to reactivate the Protractor Angular synchronization feature

Our test codebase is quite large, with around 10,000 lines of JavaScript code. In certain situations, we find it necessary to disable Protractor-to-Angular synchronization using the following line of code: browser.ignoreSynchronization = true; However, o ...

What is the internal mechanism used by Angular for routing implementation?

My traditional belief about web browsers has been challenged by the behavior of Angular. I used to think that when a user enters a new URL, the browser would fetch a whole new page from the network and display it, replacing the old one. But with Angular, ...

The hyperlink tag doesn't respond to clicks in Safari, yet functions properly in all other web browsers

I'm encountering an issue with my header drop-down menu in Safari—it works perfectly in Chrome, but when I try to open the drop-down menu in Safari, it's unresponsive. Clicking on it does nothing, preventing me from accessing other drop-downs. ...

Ways to usually connect forms in angular

I created a template form based on various guides, but they are not working as expected. I have defined two models: export class User { constructor(public userId?: UserId, public firstName?: String, public lastName?: String, ...

Checking for Object Equality in TypeScript

I'm working on a TypeScript vector library and encountered my first failed test. The issue revolves around object equality in TypeScript/JavaScript, and despite searching through TypeScript's official documentation (http://www.typescriptlang.org ...

Developing a calendar UI with similar features and functionality to Google Calendar using Ionic 2

My journey with Ionic 2 began only one week ago and has been relatively smooth sailing thus far. However, I have hit a roadblock - I need to create a calendar interface for users to book time slots. Can anyone offer assistance on how to tackle this task? ...

Endure the class attribute in Angular 5

My SearchComponent has a route (/search) and SearchDetailComponent has a route (/search-detail:id). In the SearchComponent, there is a searchbox (input field) where I can type any text to start a search. After loading the search results and navigating to ...

The utilization of *ngTemplateOutlet for conditional rendering is experiencing issues when used within a formGroup

Developed a reusable form input designed to be displayed within a form either as part of a parent formGroupName or independently as a regular input control. The code implementation is: child.component.html: <ng-container *ngIf="hasFormGroup; then f ...

Can ng-content be utilized within the app-root component?

I have successfully developed an Angular application, and now I am looking to integrate it with a content management system that generates static pages. In order to achieve this, I need to utilize content projection from the main index.html file. The desi ...

Display on click within a nested array

Within my array of teams, I have nested arrays containing players' information. JSON file "id": 1, "Name": "TEAM A", "Active": true, "created_at": "2019-09-12T13:56:52.045Z", "updated_at": "2019-09-12T14:30:42.533Z", "Players": [ { "id": 1, ...

Tips for effectively packaging the React 17 library alongside the latest JSX transformation feature as an ES Module

I am currently in the process of creating a basic library consisting of React components that I intend to publish as an ES Module package for NPM. With the utilization of React 17, I have incorporated the new JSX transform into my code. To generate the ES ...

The Response Header for JWT in Angular2 Spring Boot is not appearing

I am encountering an issue with my Angular2 client, Angular-cli, Spring Boot 1.4.0, and jwt setup. When I sign in from my Angular2 client, I am unable to retrieve the jwt token. My security configuration is as follows: @Configuration @Order(SecurityPrope ...