Errors with pointer events occurring within nested iframes on Chromium 78

At first glance, it seems like a bug specific to Chromium. I have already reported this issue in a bug report. Since progress is slow on that front, I am posting a question here primarily to see if anyone else has encountered similar or related issues and has found a workaround solution.

For the sake of readability, I will not provide HTML5 compliant code examples. Instead, I will offer simplified examples.

Description

In Chrome 78 and Edge beta browsers, when there are nested iframes with different origins overlapping an element, there are inconsistencies with the firing of pointerout/pointerover events between clicks inside the iframe - but only when there is movement of at least 1px between pointerdown and pointerup. This behavior differs from Chrome 77, Edge stable, Firefox, and Safari where these events only occur when the pointer leaves or enters the iframe, as expected.

Removing the overlapping element resolves the issue in Chrome 78, but Edge beta remains unaffected by this scenario.

When the origin of both iframes is made similar (e.g. Both localhost), the behavior is as expected in both browsers.

Reproduction

Start a server (like http-server for simplicity) in a folder containing the following files:

a.html

<iframe src="http://127.0.0.1:[port]/b.html"></iframe>
<div style="height: 3px;
    width: 300px;
    position: absolute;
    top: 159px;
    left: 10px;
    right: 0px;
    background: green;"></div>

b.html

<iframe src="http://localhost:[port]/c.html"></iframe>

c.html

<button id="btn">Click</button>

<script type="text/javascript">
    var btn = document.getElementById('btn');
    
    btn.addEventListener('pointerdown', function() { console.log('down'); });
    btn.addEventListener('pointerup', function() { console.log('up'); });
    btn.addEventListener('pointerover', function() { console.log('over'); });
    btn.addEventListener('pointerout', function() { console.log('out'); });
    btn.addEventListener('pointerleave', function() { console.log('leave'); });
</script>

Navigate to localhost/a.html, click the button, and check the console for event logs.

https://i.stack.imgur.com/t8GUS.gif

Please note that the iframe origins in a.html and b.html differ. When you navigate to 127.0.0.1 the behavior is correct, but on localhost it is not.

If you move the div in a.html outside the iframes, it functions correctly (Chrome 78 only).

Question

Are there any potential workarounds? Ideally something achievable through JS or CSS since adjusting the iframe origin and domains may not always be feasible or optimal.

As for dealing with overlapping divs, sometimes adjusting the z-index can help, but it's not always the best solution especially considering iframes can also have overlapping elements.

Answer №1

Here's a potential solution: consider comparing the coordinates in the out/leave events to the last recorded position within the button element. If the coordinates match, you can disregard the out/leave events. Additionally, it may be necessary to address the blur event.

For instance, your down handler could establish certain variables (such as current position and pressed state) while also listening for move events.

The move handler would simply update the current position.

In the out/leave handler, compare the current position with the event position. If they align and there was no blur event, dismiss the event and exit the handler. If not, cancel the press, reset variables, and unsubscribe from move events.

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

Tips for resolving the 'node-gyp rebuild' problem on Windows 10

While attempting to incorporate a node NPM dependency into my project, I encountered an issue with node-gyp rebuild, which I have already reported. I am aware of a potential solution from this Stack Overflow post, but unfortunately it is not effective for ...

Is there a way to adjust the saturation and desaturation of an image using CSS?

Issue Update After further testing, I have discovered that the desaturation effect is only functioning properly in Chrome. How can I adjust it to work in other browsers such as FF and IE? (Title modified) Currently, I am working on turning a color image ...

What is the method for aligning inline-block text to the right after a line break?

I am currently encountering a challenge in developing a directory tree using <ul> element, particularly when the text of an item exceeds the width of the container. As I am utilizing the antd React library for this project, my options are somewhat l ...

Utilizing the json_encode() function in PHP and JSON.parse() method in JavaScript for handling file data interchange

Utilizing json_encode() in PHP to store an array in a file, then leveraging JSON.parse() in JavaScript on the client side to read the json encoded file and pass it as an array to a sorting algorithm: The result of my json_encode() operation in the ...

The integration of express and cors() is malfunctioning

Currently, I am developing a React application and facing an issue while trying to make an API call to https://itunes.apple.com/search?term=jack+johnson In my project, there is a helper file named requestHelper.js with the following content : import &apo ...

Nextjs doesn't render the default JSX for a boolean state on the server side

I am working on a basic nextjs page to display a Post. Everything is functioning smoothly and nextjs is rendering the entire page server side for optimal SEO performance. However, I have decided to introduce an edit mode using a boolean state: const PostPa ...

Managing the verification of data existence in the ExpressJS service layer or controller

Working on a medium-sized website, I realized the importance of writing maintainable code with a better project structure. After stumbling upon this insightful article and some others discussing the benefits of 3-layer architecture, I found the concept qu ...

AngularJS postback method fails to trigger

Seeking assistance with my angularJS AJAX postback method. Below is the HTML code I have created: <html xmlns="http://www.w3.org/1999/xhtml" ng-app> <head runat="server"> <title></title> <script src="Scripts/angular.js ...

Guide to retriecing a state in Next.js 14

Check out my code below: "useState" // firebase.js import firebase from "firebase/app"; import "firebase/auth"; // Import the authentication module export default async function handler(req, res) { if (req.method !== " ...

Having trouble identifying the specific CSS property that is being used or inherited

I have incorporated components from Twitter Bootstrap CSS into a custom CSS file, focusing mainly on toolbar components. Specifically, I have set up a toolbar with various features. However, when applying additional CSS to the .signinbox_left:hover select ...

How can I ensure that the HTML I retrieve with $http in Angular is displayed as actual HTML and not just plain text?

I've been struggling with this issue for quite some time. Essentially, I am using a $http.post method in Angular to send an email address and message to post.php. The post.php script then outputs text based on the result of the mail() function. Howev ...

Issues occurred when attempting to access information with postgres and nodeJS

Below is the configuration I have set up in my files: const express = require('express') const app = express() const port = 8000 const expense_model = require('./expense_model') app.use(express.json()); app.us ...

Using JavaScript to locate and emphasize specific words within a text, whether they are scattered or adjacent

I need help finding a JavaScript code for searching words in a text using a form and a search button. I found one that works for multiple words in a row, but it doesn't work if the words are mixed up. What changes should be made to fix this issue? An ...

Executing a group query for Mongoose in a node.js/express route

Hey there, I have a query that works perfectly fine in Robomongo. Here's the code: db.av.group( { key: { roomId: 1}, cond: { dateOfDay: { $gte: new Date('12/01/2014'), $lt: new Date('12/30/2014') } }, reduce: function( curr, re ...

Error: Invalid parameter detected for Shopify script-tag

I'm encountering a persistent error message stating { errors: { script_tag: 'Required parameter missing or invalid' } } This issue arises when attempting to upload a script tag to a storefront. Currently, I'm just experimenting with s ...

The content in the flex box item with horizontal scroll is overflowing beyond its boundaries

I am working with a flex box container that contains two child elements: a left side and a right side. I want the right side item to have a horizontal scrollbar in order to fit its content. .container { display: flex; overflow: hidden; height: 300 ...

Error occurred in AngularJS service due to incorrect data type

Looking to store the URL of a query in an AngularJS service like this: var mortgageloanService = angular.module('loanstreetIpadAppApp', []); mortgageloanService.factory('updateTable', function($http) { return { getParams: fun ...

Collapse the sidebar using React when clicked

Just beginning to learn about React and I'm trying to figure out how to toggle the open/closed state of a react-pro-sidebar component using a click event: export default function MaterialLayout(props) { const { children } = props; const classes = us ...

Encountering problems during the installation of Ionic - Error code 'EPROTO'

After attempting to install Ionic on my system, I encountered the following error message: npm ERR! code EPROTO npm ERR! errno EPROTO npm ERR! request to https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz failed, reason: write EPROTO 0:er ...

Tips on styling HTML using a query value in string format

When using ASP.NET razor and SQL Server 2008 R2, I have a local variable declared in the following manner: var tsmMtd = db.QueryValue(" SELECT b.Name, SUM(subtotal) totalSUM FROM DR_TRANS a INNER JOIN Staff b ON a.Salesno = b.Staffno WHER ...