mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-20 23:16:17 -05:00
ui: PathInput, and the media directory stops printing over the value
The five Special Directories fields on the Settings page were unreadable: the media directory printed straight through the value, so Archive Directory showed `a/media/wrolpi/hain_tag)s/%(domain)s`. Cause: `leftSectionWidth='auto'`. Mantine turns that prop into `--input-padding-inline-start`, and `padding-inline-start: auto` is not valid CSS -- it resolves to zero, so the input reserved no room for the section positioned on top of it. It fails only in CSS, only at runtime, and nothing warns. Fixed by expressing the field in the library instead of computing a width. PathInput puts the prefix and the input side by side in a flex row sharing one outline, so there is no width to get wrong and nothing to overlap -- the failure is structurally impossible rather than merely corrected. It also sizes to any prefix, which matters because the media directory is `/media/wrolpi` on a Pi and something else under Docker. Written test-first, and the tests need no mocks at all -- no context, no fetch, no router, just the provider test-utils already supplies. That is the point: Settings.js needs a pile of provider and API mocks, so its inputs were never covered, which is how five broken fields shipped. The tests assert the things that actually matter and can be checked without layout: the prefix is a sibling rather than a child, the value never contains it, onChange reports only what was typed, the prefix is the field's accessible description so a screen-reader user knows what the path is relative to, and disabled reaches the input rather than just the wrapper. Plus a source guard, since jsdom cannot see an overlap: nothing may pass `leftSectionWidth='auto'` or `rightSectionWidth='auto'`. It strips comments first -- PathInput documents the mistake by name, and prose about a mistake is not the mistake.
This commit is contained in:
parent
d72c9e7fcc
commit
c534cbfe23
5 changed files with 272 additions and 16 deletions
|
|
@ -28,6 +28,7 @@ import {
|
|||
Select,
|
||||
ThemePicker,
|
||||
toast,
|
||||
PathInput,
|
||||
TextInput,
|
||||
} from "../ui";
|
||||
|
||||
|
|
@ -776,9 +777,8 @@ export function SettingsPage() {
|
|||
position='top'
|
||||
/>
|
||||
</label>
|
||||
<TextInput
|
||||
leftSectionWidth='auto'
|
||||
leftSection={<span style={{fontSize: '0.85em', paddingLeft: 4}}>{mediaDirectoryLabel}</span>}
|
||||
<PathInput
|
||||
prefix={mediaDirectoryLabel}
|
||||
value={state.archive_destination}
|
||||
disabled={!editSpecialDirectories}
|
||||
onChange={e => handleInputChange('archive_destination', e.currentTarget.value)}
|
||||
|
|
@ -804,9 +804,8 @@ export function SettingsPage() {
|
|||
position='top'
|
||||
/>
|
||||
</label>
|
||||
<TextInput
|
||||
leftSectionWidth='auto'
|
||||
leftSection={<span style={{fontSize: '0.85em', paddingLeft: 4}}>{mediaDirectoryLabel}</span>}
|
||||
<PathInput
|
||||
prefix={mediaDirectoryLabel}
|
||||
value={state.videos_destination}
|
||||
disabled={!editSpecialDirectories}
|
||||
onChange={e => handleInputChange('videos_destination', e.currentTarget.value)}
|
||||
|
|
@ -814,9 +813,8 @@ export function SettingsPage() {
|
|||
</Grid.Col>
|
||||
<Grid.Col span={{base: 12, sm: 6}}>
|
||||
<label>Map Directory</label>
|
||||
<TextInput
|
||||
leftSectionWidth='auto'
|
||||
leftSection={<span style={{fontSize: '0.85em', paddingLeft: 4}}>{mediaDirectoryLabel}</span>}
|
||||
<PathInput
|
||||
prefix={mediaDirectoryLabel}
|
||||
value={state.map_destination}
|
||||
disabled={!editSpecialDirectories}
|
||||
onChange={e => handleInputChange('map_destination', e.currentTarget.value)}
|
||||
|
|
@ -824,9 +822,8 @@ export function SettingsPage() {
|
|||
</Grid.Col>
|
||||
<Grid.Col span={{base: 12, sm: 6}}>
|
||||
<label>Zims Directory</label>
|
||||
<TextInput
|
||||
leftSectionWidth='auto'
|
||||
leftSection={<span style={{fontSize: '0.85em', paddingLeft: 4}}>{mediaDirectoryLabel}</span>}
|
||||
<PathInput
|
||||
prefix={mediaDirectoryLabel}
|
||||
value={state.zims_destination}
|
||||
disabled={!editSpecialDirectories}
|
||||
onChange={e => handleInputChange('zims_destination', e.currentTarget.value)}
|
||||
|
|
@ -834,9 +831,8 @@ export function SettingsPage() {
|
|||
</Grid.Col>
|
||||
<Grid.Col span={{base: 12, sm: 6}}>
|
||||
<label>Playlists Directory</label>
|
||||
<TextInput
|
||||
leftSectionWidth='auto'
|
||||
leftSection={<span style={{fontSize: '0.85em', paddingLeft: 4}}>{mediaDirectoryLabel}</span>}
|
||||
<PathInput
|
||||
prefix={mediaDirectoryLabel}
|
||||
value={state.playlists_destination}
|
||||
disabled={!editSpecialDirectories}
|
||||
onChange={e => handleInputChange('playlists_destination', e.currentTarget.value)}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue