From ad6fe47a950ba66794b6b947911c628a5520feda Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Tue, 16 Jun 2026 17:33:51 -0700 Subject: [PATCH] Better way of setting min height on CodeMirror Previously there were four lines of whitespace, but that meant users had to delete that whitespace themselves when they started editing. Now it is four lines tall without that. --- datasette/templates/execute_write.html | 15 +++++++-------- tests/test_queries.py | 4 +++- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/datasette/templates/execute_write.html b/datasette/templates/execute_write.html index 0d0a9931..592577f8 100644 --- a/datasette/templates/execute_write.html +++ b/datasette/templates/execute_write.html @@ -56,6 +56,11 @@ form.sql.core input[data-execute-write-submit]:disabled { cursor: not-allowed; opacity: 1; } +.execute-write form.sql .sql-editor-min-lines .cm-content, +.execute-write form.sql .sql-editor-min-lines .cm-gutter { + /* Four visible editor lines without adding blank lines to the SQL value. */ + min-height: calc(5.6em + 8px); +} .execute-write-disabled-reason { color: #4f5b6d; font-size: 0.85rem; @@ -119,7 +124,7 @@ form.sql.core input[data-execute-write-submit]:disabled {

There are no tables that you can currently edit.

{% endif %} -

+

{% set sql_parameters_section_id = "execute-write-parameters-section" %} {% set sql_parameters_allow_expand = true %} @@ -164,19 +169,13 @@ form.sql.core input[data-execute-write-submit]:disabled {

- - {% include "_codemirror_foot.html" %} {% include "_sql_parameter_scripts.html" %} {% include "_execute_write_analysis_scripts.html" %}