Skip to content

Commit 5fd5d1a

Browse files
committed
Better max character support
Signed-off-by: worksofliam <[email protected]>
1 parent f443439 commit 5fd5d1a

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/views/results/html.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ function handleCellResponse(id, success) {
7474
}
7575
}
7676
77+
const validKeyPresses = ['Enter', 'Backspace', 'Delete', 'ArrowLeft', 'ArrowRight'];
78+
7779
document.getElementById('resultset').onclick = function(e){
7880
console.log('click')
7981
if (updateTable === undefined) return;
@@ -123,9 +125,15 @@ document.getElementById('resultset').onclick = function(e){
123125
editableNode.focus();
124126
125127
const keydownEvent = (e) => {
126-
if (e.key === 'Enter') {
128+
if (chosenColumnDetail.maxInputLength && editableNode.innerText.length >= chosenColumnDetail.maxInputLength) {
129+
if (!validKeyPresses.includes(e.key)) {
130+
e.preventDefault();
131+
}
132+
}
133+
134+
if (e.key === 'Enter') {
127135
e.preventDefault();
128-
finishEditing(e.target);
136+
finishEditing();
129137
}
130138
}
131139
@@ -205,7 +213,7 @@ document.getElementById('resultset').onclick = function(e){
205213
e.stopPropagation();
206214
console.log('blur');
207215
// Code to execute when the element loses focus
208-
finishEditing(e.target);
216+
finishEditing();
209217
}, {once: true});
210218
211219
editableNode.addEventListener('keydown', keydownEvent);

0 commit comments

Comments
 (0)