From 36d18ba5cb81d46ad9ec6789c628921cd280a30a Mon Sep 17 00:00:00 2001 From: Aditya Toshniwal Date: Wed, 29 Mar 2023 13:49:11 +0530 Subject: [PATCH] Changes in accesskey display code to reflect all supported browser+OS combinations. #5022 --- .../static/js/components/ShortcutTitle.jsx | 27 +++++-------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/web/pgadmin/static/js/components/ShortcutTitle.jsx b/web/pgadmin/static/js/components/ShortcutTitle.jsx index d822f3d5e..930eddf78 100644 --- a/web/pgadmin/static/js/components/ShortcutTitle.jsx +++ b/web/pgadmin/static/js/components/ShortcutTitle.jsx @@ -25,35 +25,22 @@ const useStyles = makeStyles((theme)=>({ })); export function getBrowserAccesskey() { - /* Ref: https://github.com/tillsanders/access-key-label-polyfill/ */ + /* Ref: https://www.w3schools.com/tags/att_accesskey.asp */ let ua = window.navigator.userAgent; // macOS if (ua.match(/macintosh/i)) { - // Firefox - if (ua.match(/firefox/i)) { - const firefoxVersion = ua.match(/firefox[\s/](\d+)/i); - // Firefox < v14 - if (firefoxVersion[1] && parseInt(firefoxVersion[1], 10) < 14) { - return ['Ctrl']; - } - } - return ['Option', 'Ctrl']; + return ['Ctrl', 'Option']; } - // Internet Explorer / Edge - if (ua.match(/msie|trident/i) || ua.match(/\sedg/i)) { + // Windows / Linux + if (ua.match(/windows/i) || ua.match(/linux/i)) { + if(ua.match(/firefox/i)) { + return ['Alt', 'Shift']; + } return ['Alt']; } - // iOS / iPadOS - if (ua.match(/(ipod|iphone|ipad)/i)) { - // accesskeyLabel is supported > v14, but we're not checking for versions here, since we use - // feature support detection - return ['Option', 'Ctrl']; - } - // Fallback - // Note: Apparently, Chrome for Android is not even supporting accesskey, so be prepared. return [gettext('Accesskey')]; }