Fix Commands button to show correct shortcut on Windows and Linux (#3625)
* Fix Commands button to show correct shortcut
* Fix onboarding to use the same shortcut reference
* Rename test file to be more general
* Add test for commands button text
* Remove outdated reference to Ctrl+/
* Change shortcut separator to be + and no spaces
* Add JSDocs and improve comments
* Add unit tests
* Change control modifier to regular ASCII caret
* Add browser test and fix platform detection
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest)
* Add useful debug info to the error message
* Fix to display metaKey as Super on Linux
* Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest)"
This reverts commit f8da90d5d2
.
* A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest)
* Approve snapshots
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Jess Frazelle <jessfraz@users.noreply.github.com>
This commit is contained in:
@ -151,6 +151,32 @@ export function platform(): Platform {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
// navigator.platform is deprecated, but many browsers still support it, and
|
||||
// it's more accurate than userAgent and userAgentData in Playwright.
|
||||
if (
|
||||
navigator.platform?.indexOf('Mac') === 0 ||
|
||||
navigator.platform === 'iPhone'
|
||||
) {
|
||||
return 'macos'
|
||||
}
|
||||
if (navigator.platform === 'Win32') {
|
||||
return 'windows'
|
||||
}
|
||||
|
||||
// Chrome only, but more accurate than userAgent.
|
||||
let userAgentDataPlatform: unknown
|
||||
if (
|
||||
'userAgentData' in navigator &&
|
||||
navigator.userAgentData &&
|
||||
typeof navigator.userAgentData === 'object' &&
|
||||
'platform' in navigator.userAgentData
|
||||
) {
|
||||
userAgentDataPlatform = navigator.userAgentData.platform
|
||||
if (userAgentDataPlatform === 'macOS') return 'macos'
|
||||
if (userAgentDataPlatform === 'Windows') return 'windows'
|
||||
}
|
||||
|
||||
if (navigator.userAgent.indexOf('Mac') !== -1) {
|
||||
return 'macos'
|
||||
} else if (navigator.userAgent.indexOf('Win') !== -1) {
|
||||
@ -158,7 +184,12 @@ export function platform(): Platform {
|
||||
} else if (navigator.userAgent.indexOf('Linux') !== -1) {
|
||||
return 'linux'
|
||||
}
|
||||
console.error('Unknown platform userAgent:', navigator.userAgent)
|
||||
console.error(
|
||||
'Unknown platform userAgent:',
|
||||
navigator.platform,
|
||||
userAgentDataPlatform,
|
||||
navigator.userAgent
|
||||
)
|
||||
return ''
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user