HomeSeer / Plugin-SDK

Plugin development kit for the 4th major edition of the HomeSeer platform.
https://www.nuget.org/packages/HomeSeer-PluginSDK/
GNU Affero General Public License v3.0
20 stars 4 forks source link

Issue since latest update of Chrome with event logic - breaking many of my plugins! #317

Closed stefxx closed 1 year ago

stefxx commented 2 years ago

Environment

HomeSeer

OS

Windows

HS Version

[v4.2.15.0]

Development

PSDK Version

[v1.4.2.0]

Language

[VB]

IDE

[VS2019]

Dev OS

[Windows]

Plugin

Pushover, UniFi, LG ThinQ etc.

Problem

Since the latest release of Chome (105.0.5195.102) and Edge new events generate an error after InitFullConfigPage and new event properties are not being shown. The following error is in the browser console debug window: Uncaught TypeError: Cannot read properties of undefined (reading 'getAttribute') at HTMLSelectElement.viewValueChanged (events.html?ref=2&su…=event.html:1321:30) at HTMLDocument.dispatch (jquery-3.4.0.min.js:2:42523) at v.handle (jquery-3.4.0.min.js:2:40524) at MaterialSelect._triggerChangeOnNativeSelect (mdb.js:18418:35) at MaterialSelect._onEachMaterialOptionClick (mdb.js:18395:14) at HTMLLIElement.dispatch (jquery-3.4.0.min.js:2:42523) at v.handle (jquery-3.4.0.min.js:2:40524) viewValueChanged @ events.html?ref=2&su…age=event.html:1321 dispatch @ jquery-3.4.0.min.js:2 v.handle @ jquery-3.4.0.min.js:2 _triggerChangeOnNativeSelect @ mdb.js:18418 _onEachMaterialOptionClick @ mdb.js:18395 dispatch @ jquery-3.4.0.min.js:2 v.handle @ jquery-3.4.0.min.js:2

Description

Users of several of my plugins cannot create new events anymore. Using Firefox is still working fine.

Expected Behavior

New properties defined in InitFullConfigPage should be displayed as before.

Steps to Reproduce

Install Pushover, LG ThinQ or UniFi (probably best to use Pushover as that is most easy to configure) and create an Pushover event. After selecting the message type to be send, the problem will be obvious.

Screenshots

See forum post: https://forums.homeseer.com/forum/hs4-products/hs4-plugins/phone-text-email-plug-ins-aa/pushover-stefxx/1564440-weird-behavior-in-chrome-vs-firefox

Logs

Let me know what more information you need!

stefxx commented 2 years ago

I just tested with the latest version of the Sample plugin; same issue. Probably much easier to replicate!

Just start the Sample plugin, create an event, select "Sample plugin action - Write to log" and select any "Log type". It stops right there with the same error in the Console debug.

spudwebb commented 2 years ago

I can reproduce the problem. Tracked as HS-1713 Seems to be a breakage in Chrome version 105 and some jquery instructions: https://github.com/jquery/jquery/issues/5098

stefxx commented 2 years ago

Thanks Spudd, appreciate your confirmation. Seems like a Chromium bug. Or can this (also?) be solved within HS4?

alexbk66 commented 2 years ago

Same here https://forums.homeseer.com/forum/hs4-products/hs4-plugins/internet-network-plug-ins-aa/ak-google-calendar-alexbk66-aa/1455042-create-event-can-select-calendar-but-will-not-save#post1565003

avargaskun commented 2 years ago

I just ran into this as well using Edge. It looks like the :has CSS selector is not officially supported by all major browsers: https://developer.mozilla.org/en-US/docs/Web/CSS/:has#browser_compatibility and a recent Chromium change broke it.

I would recommend rather than waiting for a fix in Chromium, we could insulate HS from future breaking changes to :has and replace its use with vanilla jQuery for DOM traversal. There are only 4 lines in /html/bootstrap/js/jui-events.js that use :has and can be easily switched to use jQuery's .parents().

For example, replacing lines 178-179:

var viewIdEscaped = view.id.replace(/\./g, '\\.');
var pagediv = $('div.container.jui-page:has(#' + viewIdEscaped + ')')[0];

With the following:

var pagediv = $(view).parents('div.container.jui-page')[0];

I've attached a fully patched jui-events.js file based on HS 4.2.14.0 jui-events.js.txt

alexbk66 commented 2 years ago

User will40 also confirmed that the patch works https://forums.homeseer.com/forum/hs4-products/hs4-plugins/internet-network-plug-ins-aa/ak-google-calendar-alexbk66-aa/1455042-create-event-can-select-calendar-but-will-not-save-chrome-ms-edge-not-firefox?p=1565082#post1565082

spudwebb commented 2 years ago

This problem is fixed in Chrome 106.0.5249.30 available as a beta version But you're right, we should replace the :has CSS selector with something else to prevent future problems.

alexbk66 commented 2 years ago

I applied the jui-events.js patch and it works.

spudwebb commented 1 year ago

This issue is fixed in HS version 4.2.16.0