sindresorhus / caprine

Elegant Facebook Messenger desktop app
MIT License
7.04k stars 557 forks source link

Use aria-label for Preferences selector #2181

Open mquevill opened 5 months ago

mquevill commented 5 months ago

The selector that was previously used is also used for Security Alerts (including entering in your message sync PIN) and other windows, so it would be difficult to use that style of selector. Using aria-label=Preferences seems to be the best way to address this.

The current method used elementReady() on the first element that matched, which was usually the Sync PIN window, which caused some other conflicts with how the typical code flow would work.

The extra "style" code is no longer necessary with the backend design changes. (It's probably been outdated for some time...)

Fixes #2167.

logiclrd commented 4 months ago

In #2167, there is a comment indicating that the reason the security dialog doesn't show up is that the root element has class hide-preferences-window. Empirically, I can confirm that removing this class makes the security dialog show up. This PR is marked as fixing #2167, but won't hide-preferences-window still be on the root element??

mquevill commented 4 months ago

In #2167, there is a comment indicating that the reason the security dialog doesn't show up is that the root element has class hide-preferences-window. Empirically, I can confirm that removing this class makes the security dialog show up. This PR is marked as fixing #2167, but won't hide-preferences-window still be on the root element??

The hide-preferences-window class affects all pop-ups (preferences window, sync messages window, etc.) and should be removed after the hidden preferences window is closed. The issue has been that the function isPreferencesOpen() would return true even if the "Sync now" dialog was open. By switching to the aria-label, it's more specific to the preferences window only. This means that the code will correctly detect when that window closes and the hide-preferences-window class can be removed.