Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #11794 from mcirlanaru/bug_908329
Browse files Browse the repository at this point in the history
Bug 908329 - [Keyboard] Update alternatives menu width logic. r=@davidflanagan
  • Loading branch information
mihai committed Sep 10, 2013
2 parents 95ea832 + dda1e65 commit 0d22609
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion apps/keyboard/js/layout.js
Expand Up @@ -472,7 +472,7 @@ const Keyboards = {
i: 'ìíîïī',
o: 'öòóôõōœø',
u: 'üùúûū',
s: 'śšşß',
s: 'ßśšş',
S: 'ŚŠŞ',
n: 'ńñň'
},
Expand Down
11 changes: 7 additions & 4 deletions apps/keyboard/js/render.js
Expand Up @@ -550,7 +550,7 @@ const IMERender = (function() {
key.dataset.compositeKey.length : 1;

// Build a key for each alternative
altChars.forEach(function(alt) {
altChars.forEach(function(alt, index) {
var dataset = alt.length == 1 ?
[{'key': 'keycode', 'value': alt.charCodeAt(0)}] :
[{'key': 'compositekey', 'value': alt}];
Expand All @@ -559,9 +559,12 @@ const IMERender = (function() {
// it is an alternative for, but adjust for the relative number of
// characters in the original and the alternative
var width = 0.75 * key.offsetWidth / keycharwidth * alt.length;
// If there is only one alternative, then display it at least as
// wide as the original key.
if (altChars.length === 1)
// If there is only one alternative, or we are showing the first
// alternative character, then display it at least as wide as the
// original key.
if (altChars.length === 1 ||
(left && index === 0) ||
(!left && index === altChars.length - 1))
width = Math.max(width, key.offsetWidth);

content.appendChild(buildKey(alt, '', width + 'px', dataset));
Expand Down

0 comments on commit 0d22609

Please sign in to comment.