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

Responsive slide displays a unique number of items per slide depending

I created a logo slider using Bootstrap, similar to the one showcased here: http://jsfiddle.net/juddlyon/Q2TYv/10/. Currently, each slide in the slider displays 4 logos. I would like to make it responsive so that on smaller screens, only 2 logos are shown ...

What is the best way to insert an <image> tag into the SVG DOM?

Currently, I am facing an issue with adding a background image to the generated SVG DOM in my web page. The user interacts by drawing an SVG doodle on top of a jpg image using Raphael. After the user is done with their drawing, I want to enable them to sa ...

An error occurred when attempting to search for 'length' using the 'in' operator in the context of the Datatables plugin and jQuery 1.11.3

I implemented the jQuery Datatables plugin in my tables for pagination, sorting, and searching functionalities. However, I am facing issues where the elements are not working properly, and the pagination occasionally fails to display. The Chrome console is ...

Tips for creating Selenium code to verify the asterisk symbol

Looking to create Selenium code for validating the presence of asterisks with mandatory fields such as First Name*, Last Name*, Enter Address*, and Enter Phone Number*. The validation needs to confirm the asterisk appears after each field name. Currently ...

Custom headers in XmlHttpRequest: Access control check failed for preflight response

Encountering an issue with an ajax GET Request on REST Server. Test results and details provided below. There are two methods in the REST Server: 1) resource_new_get (returns json data without custom header) 2) resource_api_new_get (also returns json d ...

Having trouble obtaining outcomes from Cloud Code in Parse

After struggling with this issue for quite some time, I have reached a point where I feel the need to seek help. I am working on a cloud code function that is supposed to retrieve a list of categories along with their respective products. Each category con ...

Assessing the performance of YUi and BackBone

As I embark on a new project, one of the crucial decisions to make is regarding the architecture. Currently, I am contemplating the selection of front-end components. I plan to utilize HTML5, CSS3, and Javascript for this purpose. When it comes to choos ...

How can I adjust the position of a target point in the chase camera using THREE.js?

Recently, I've delved into the world of THREE.js and decided to create a game featuring a spaceship as the main element. Utilizing a chase camera for my model, I encountered a challenge where I needed to adjust the camera's position in relation t ...

In React, the Textarea component that displays the character count only updates its value after a page reload

Contained within this element is the following component: import React, { useEffect, useState } from 'react'; import { TextareaTestIds } from '../utils/test-ids'; export interface TexareaProps extends React.TextareaHTMLAttributes<H ...

including a collection of values into a JSON data structure

Currently, I am iterating through some JSON data (grouped tweets from Twitter) to tally the frequency of specific keywords (hashtags) in order to generate an organized list of common terms. this (19) that (9) hat (3) I have achieved this by initial ...

Implement Babel with node.js 6.9

It puzzles me why some folks opt to use Babel for their Node.js projects. I personally utilize node 6.9 and have no issues writing ES6 code - from default arguments in functions to arrow functions, rest parameters, and spread syntax. Do you think Babel is ...

The condition is not established by the Firestore where clause

I'm working on a function that includes two where clauses. My objective is to verify the existence of a document based on the presence of two specific IDs. However, when I execute the function, it retrieves all the records in the collection instead. C ...

Applying a switch case to dynamically alter the background image using CSS depending on the specific case

Currently, I am working on implementing a feature that allows users to switch the background image of the cropper based on the crop operation ratios they select (SQUARE/PORTRAIT/LANDSCAPE). To achieve this, I plan to set three variables representing each ...

"Utilizing SVG format to manipulate text, adjusting font size within tspan elements

There seems to be an issue with the font size on SVG. Even though both the SVG and paragraph have a font-size of 16px, they appear different. I would like the font size in the SVG to match that of the paragraph. Another concern is how to center <tspan ...

User interface for creating a platform resembling Product Hunt or Reddit

I am currently developing a web application similar to Product Hunt. The back-end API is up and running smoothly, and I have successfully implemented AngularJS for the front-end. However, I lack experience in designing the look and feel of the site. Shou ...

Dynamically filling a second dropdown menu according to the selection made in the first dropdown using AJAX and PHP

Help! I'm feeling a bit overwhelmed. Even though this question has been answered multiple times, I still can't figure it out. There must be something so obvious that I am missing. I want the options in the second select input to be populated dyn ...

Encountering a 'Not Found' error while deploying my React Node application with an AWS-hosted database on Heroku

const express = require("express"); const app = express(); const bodyParser = require("body-parser"); const port = process.env.PORT || 3002; const cors = require("cors"); const path=require("path"); const routing = ...

Steps for Customizing the Font Style of a Certain List Item Tag <li>

I'm struggling to find the right CSS selector to specifically change the font of just one list item. Here's the current structure: <ul id="menu-applemain class="x-nav> <li>One</li> <li>Two</li> <li>Three</l ...

Phonegap experiencing issues with executing JavaScript code

My attempt to utilize phonegap is encountering an issue where my javascript is not running. Here's what I've tried so far: <html> <head> <meta charset="utf-8" /> <meta name="format-detection" content="telephone=no" / ...

Two approaches for one single object

I'm trying to figure out why this particular code works // ....................................................... var character = { name: 'Joni', type: 'blond', sayName: function() { return this.name; }, sayT ...