@autobusal/common 1.4.4 → 1.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { useState, useRef, ChangeEvent, KeyboardEvent } from 'react';
1
+ import { useState, useRef, useEffect, ChangeEvent, KeyboardEvent } from 'react';
2
2
  import { TFunction } from 'i18next';
3
3
  import { UseFormRegister, UseFormSetValue } from 'react-hook-form';
4
4
  import { useOutside } from '@autobusal/hooks';
@@ -31,6 +31,21 @@ const Autocomplete = ({ name, defaultValue, data, validation, t, refs, onUpdate
31
31
 
32
32
  useOutside(ref, () => setShow(false));
33
33
 
34
+ // `data` is rebuilt with fresh (locale-specific) names whenever the
35
+ // language changes, but `q` is plain component state that React won't
36
+ // resync on its own - without this, a selected station keeps showing
37
+ // its display name in the language that was active at selection time.
38
+ useEffect(() => {
39
+ if (value) {
40
+ const match = data.find(item => item.value === value);
41
+
42
+ if (match) {
43
+ setQ(match.name);
44
+ }
45
+ }
46
+ // eslint-disable-next-line react-hooks/exhaustive-deps
47
+ }, [ data ]);
48
+
34
49
  const options = data.filter(item => {
35
50
  return item.name.toLowerCase().indexOf(q.toLowerCase()) > -1;
36
51
  });
package/CHANGELOG.md CHANGED
@@ -3,6 +3,18 @@
3
3
  All notable changes to `@autobusal/common` are documented here. This project follows
4
4
  [Keep a Changelog](https://keepachangelog.com/) and [Semantic Versioning](https://semver.org/).
5
5
 
6
+ ## [1.4.6] - 2026-07-29
7
+
8
+ ### Fixed
9
+
10
+ - `Autocomplete/Autocomplete.tsx`: the "From"/"To" route-search inputs kept showing a station's display name in the language that was active when it was selected, since the displayed text (`q`) was plain component state that never resynced when `data` was rebuilt with fresh, relocalized names after a language switch (e.g. "(Alle Stationen)" stayed baked in after switching German -> English). Now re-derives the display name from the selected `value` whenever `data` changes.
11
+
12
+ ## [1.4.5] - 2026-07-28
13
+
14
+ ### Fixed
15
+
16
+ - `File/File.tsx`: a `required` file-input field blocked saving ANY record that already had a file (image, document, etc.) unless the user re-uploaded it, since a file input can never carry over its previous value - the `required` rule now skips when a `value` (existing file URL) is already present. Found via a live sanity pass: this froze several existing records (e.g. a bus with a real image) out of being editable at all.
17
+
6
18
  ## [1.4.4] - 2026-07-24
7
19
 
8
20
  ### Fixed
package/File/File.tsx CHANGED
@@ -24,6 +24,13 @@ const File = ({ name, value, validation, multiple, t, refs }: Props): JSX.Elemen
24
24
 
25
25
  const rules = Validate(String(validation), t);
26
26
 
27
+ // a file input can never carry over its previous value (browsers won't let
28
+ // us set one), so `required` would otherwise force a re-upload just to save
29
+ // an unrelated field on a record that already has a file
30
+ if (value) {
31
+ delete rules.required;
32
+ }
33
+
27
34
  const onChange = (): void => {
28
35
  setUploaded(true);
29
36
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autobusal/common",
3
- "version": "1.4.4",
3
+ "version": "1.4.6",
4
4
  "author": "Ferjolt Ozuni",
5
5
  "type": "module",
6
6
  "main": "index.ts"