Skip to content

Commit 13055be

Browse files
committed
Config HTML repr: prevent notebook keyboard shortcuts from interfering with search input
1 parent 5d77875 commit 13055be

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

sourcespec2/setup/config_helpers.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,21 @@ def generate_html_repr(
283283
const table = document.getElementById('table_{unique_id}');
284284
const rows = table.getElementsByClassName('data-row');
285285
if (searchInput) {{
286+
// Prevent notebook keyboard shortcuts from interfering
287+
// with search input
288+
searchInput.addEventListener('keydown', function(event) {{
289+
// Don't stop propagation for Ctrl/Cmd combinations
290+
// (e.g., Ctrl+A, Ctrl+C)
291+
// These should work normally in the input field
292+
if (event.ctrlKey || event.metaKey) {{
293+
return;
294+
}}
295+
// Stop all other keys from reaching the notebook
296+
event.stopPropagation();
297+
}});
298+
searchInput.addEventListener('keyup', function(event) {{
299+
event.stopPropagation();
300+
}});
286301
searchInput.addEventListener('input', function() {{
287302
const searchText = this.value.toLowerCase();
288303
for (let i = 0; i < rows.length; i++) {{

0 commit comments

Comments
 (0)