Keep input tooltips to the name and switching shortcut

This commit is contained in:
David Heinemeier Hansson committed 2026-10-09 14:44:27 +02:00
1 parent f0ff594ee3
commit 203654bead
2 files changed
+4 -8

No files matched your search

@@ -120,11 +120,7 @@ function inputLabel(state, fallback) {
function inputTooltip(state, layout, multipleLayouts) {
if (!state || !state.methods || state.methods.length < 2)
return layout + (multipleLayouts ? "" : "\nClick to set up an input language")
var text = state.name + "\nClick to switch input language\nSuper + I to toggle input"
if (state.methods.indexOf("mozc") !== -1)
text += "\nJapanese: type a word, then Space twice for character choices"
if (multipleLayouts) text += "\nRight-click to switch keyboard layout"
return text
return (state.name || layout).replace(/^Keyboard - /, "") + " · Super + I"
}
function showIndicator(layoutLabel, multipleLayouts, multipleInputs) {
+3 -3
View File
@@ -14,9 +14,9 @@ assertEqual(model.inputLabel({ ...japanese, current: 'keyboard-us' }, 'EN'), 'EN
assertEqual(model.inputLabel({}, 'EN'), 'EN', 'a stopped input service retains the keyboard label')
assertEqual(model.inputLabel({ current: 'hangul' }, 'EN'), '한', 'Korean input has a distinct label')
assertEqual(model.inputLabel({ current: 'custom', language: 'vi' }, 'EN'), 'VI', 'other engines use their reported language')
assertEqual(model.inputTooltip(japanese, 'English (US)', false).includes('Space twice'), true, 'Japanese explains character choices')
assertEqual(model.inputTooltip(japanese, 'English (US)', false).includes('Super + I'), true, 'the input toggle shortcut is discoverable')
assertEqual(model.inputTooltip(japanese, 'English (US)', true).includes('Right-click'), true, 'combined input and layout switching stays discoverable')
assertEqual(model.inputTooltip(japanese, 'English (US)', false), 'Mozc · Super + I', 'input tooltip shows only its name and shortcut')
assertEqual(model.inputTooltip(japanese, 'English (US)', true), 'Mozc · Super + I', 'multiple layouts keep the input tooltip compact')
assertEqual(model.inputTooltip({ ...japanese, current: 'keyboard-us', name: 'Keyboard - English (US)' }, 'English (US)', false), 'English (US) · Super + I', 'Latin input omits the redundant keyboard prefix')
assertEqual(model.inputTooltip({ methods: ['keyboard-fr'] }, 'French', false), 'French\nClick to set up an input language', 'one foreign mode offers input setup')
assertEqual(model.showIndicator('EN', false, false), false, 'English alone stays hidden')
assertEqual(model.showIndicator('ENG', false, false), false, 'English before the brief table loads stays hidden')