Text Fields in Lists on macOS SwiftUI

Today’s post is a bug report. I’ve sent a developer feed back to Apple already but got no response yet. I don’t know exactly when Apple introduced this bug. But it may well be with the first release of macOS Ventura (13.0) and it’s still not fixed as of macOS 13.4.1.

At that time I’ve noticed that the text fields of one of my macOS Apps got an unintended left padding when included in a List. Here is a very simple test code to demonstrate the problem:

First of all I’d like to compare the behaviour of Text and a TextField outside of a List (lines 5-10). To make the alignment of the TextField more visible I’ve modified it with the SquareBorderTextFieldStyle. 

As you can see the Text and the TextField are nicely left aligned. But when you put that in a List (lines 12-17) the alignment is gone. The TextField gets an unintended additional left padding of 8 px.

You can get hold of this problem by applying a negative leading padding but you have to distinguish between TextField within a List and outside. This is quite annoying.

Update September, 29 2023:

Good news. With macOS 14 Sonoma the problem disappeared. No workaround necessary any more.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert