Skip to content

Commit 23995b3

Browse files
authored
Adding inputmode numeric to integer fields (#17753)
* Adding inputmode numeric to integer fields To easier use phpMyAdmin on touch devices with virtual keyboards, adding the inputmode ensures that the correct virtual keyboard is shown per default when focusing the field. See https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode for more information. Related to #17745. Signed-off-by: Jesper Skytte <jesper@skytte.it>
1 parent ba02d77 commit 23995b3

3 files changed

Lines changed: 31 additions & 2 deletions

File tree

libraries/classes/InsertEdit.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,8 @@ private function getHtmlInput(
694694
}
695695

696696
$inputMinMax = '';
697-
if (in_array($column['True_Type'], $this->dbi->types->getIntegerTypes())) {
697+
$isInteger = in_array($column['True_Type'], $this->dbi->types->getIntegerTypes());
698+
if ($isInteger) {
698699
$extractedColumnspec = Util::extractColumnSpec($column['Type']);
699700
$isUnsigned = $extractedColumnspec['unsigned'];
700701
$minMaxValues = $this->dbi->types->getIntegerRange($column['True_Type'], ! $isUnsigned);
@@ -716,6 +717,7 @@ private function getHtmlInput(
716717
. ' data-type="' . $dataType . '"'
717718
. ' class="' . $theClass . '" ' . $onChangeClause
718719
. ' tabindex="' . ($tabindex + $tabindexForValue) . '"'
720+
. ($isInteger ? ' inputmode="numeric"' : '')
719721
. ' id="field_' . $idindex . '_3">';
720722
}
721723

test/classes/Controllers/Table/ChangeControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function testChangeController(): void
5858
. ' size="4" min="-2147483648" max="2147483647" data-type="INT" class="textfield"'
5959
. ' onchange="return'
6060
. ' verificationsAfterFieldChange(\'b80bb7740288fda1f201890375a60c8f\', \'0\',\'int(11)\')"'
61-
. ' tabindex="1" id="field_1_3"><input type="hidden"'
61+
. ' tabindex="1" inputmode="numeric" id="field_1_3"><input type="hidden"'
6262
. ' name="auto_increment[multi_edit][0][b80bb7740288fda1f201890375a60c8f]" value="1">',
6363
$actual
6464
);

test/classes/InsertEditTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,6 +1052,33 @@ public function testGetHTMLinput(): void
10521052
. ' class="textfield datetimefield" c tabindex="25" id="field_0_3">',
10531053
$result
10541054
);
1055+
1056+
// case 4 int
1057+
$column['pma_type'] = 'int';
1058+
$column['True_Type'] = 'int';
1059+
$column['Type'] = 'int(11)';
1060+
$result = $this->callFunction(
1061+
$this->insertEdit,
1062+
InsertEdit::class,
1063+
'getHtmlInput',
1064+
[
1065+
$column,
1066+
'a',
1067+
'b',
1068+
11,
1069+
'c',
1070+
23,
1071+
2,
1072+
0,
1073+
'INT',
1074+
false,
1075+
]
1076+
);
1077+
$this->assertEquals(
1078+
'<input type="text" name="fieldsa" value="b" size="11" min="-2147483648" max="2147483647" data-type="INT"'
1079+
. ' class="textfield" c tabindex="25" inputmode="numeric" id="field_0_3">',
1080+
$result
1081+
);
10551082
}
10561083

10571084
/**

0 commit comments

Comments
 (0)