Skip to content

Edit: Fix JavaScript error with a nullable boolean column - #1364

Merged
vrana merged 2 commits into
vrana:mainfrom
landsman:bool-function-change
Oct 23, 2026
Merged

vrana merged 2 commits into
vrana:mainfrom
landsman:bool-function-change

Conversation

@landsman

Copy link
Copy Markdown
Contributor

Opening the edit form of a row with a nullable boolean column throws on load, before anything is clicked:

TypeError: Cannot read properties of undefined (reading 'toggle')
    at alterClass (functions.js)
    at HTMLSelectElement.functionChange (functions.js)
    at fire (functions.js)

To reproduce on PostgreSQL:

CREATE TABLE t (id int PRIMARY KEY, b boolean);
INSERT INTO t VALUES (1, true);

Open ?pgsql=…&edit=t&where[id]=1 and look at the console. New item throws too.

input() renders a boolean as <input type='hidden'> plus <input type='checkbox'>, both named fields[b], and the column being nullable gives it a function select, whose initial fire(…, 'change') runs functionChange(). There, this.form['fields[b]'] is a RadioNodeList, which has no classList, and alterClass() only guards against null. A NOT NULL boolean has no function select, so it doesn't throw.

The fix takes the checkbox out of the RadioNodeList. The test in pgsql.spec.js opens the edit form of the existing types table (its o boolean is nullable) and fails without the fix through expectNoErrors().

@vrana
vrana merged commit 2d90ae0 into vrana:main Oct 23, 2026
1 check passed
@landsman
landsman deleted the bool-function-change branch October 23, 2026 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants