Skip to content

fix(Upload): value prop is added#89

Merged
aktasmehmet merged 5 commits into
mainfrom
feature/upload_components_value_implement
Jun 22, 2026
Merged

fix(Upload): value prop is added#89
aktasmehmet merged 5 commits into
mainfrom
feature/upload_components_value_implement

Conversation

@aktasmehmet

Copy link
Copy Markdown
Contributor

Description

This PR basically integrates files already in the server, into the Upload components (UploadDragger, List, Input) with the value prop. In order to achieve this, a new external type is introduced and components are fixed to map that type to the internal file types. Form side registrations are also enhanced.

I tried to gather together the changes I've made and issues I've faced below. They are not all of the changes but at least this gives an insight.

Issue Severity Detail
uploaded: true missing Critical Added to initializer; guards in validation, removeFiles, and maxFile checks all key off f.uploaded
STATUS.UPLOADED → reuse SUCCESS Design Reverted new status; server files use STATUS.SUCCESS with uploaded: true
Download button gate High FileButton checks file.download instead of a dedicated status
Validation guard Critical f.uploaded === true causes early return, skipping size/type/count checks for server files
removeFiles routing High Server files (f.uploaded) go to _deleteFilesFromServer instead of local-only removal
maxFile counting High Both DragAreas now use f.status !== STATUS.CHECK_FAIL to count occupied slots
_isSameFile ignores server files High Removed lastModified from comparison; now matches on name + size + type only
file is a plain object cast as File Low FileType.file narrowed to Pick<File, 'name'|'size'|'type'>; as File cast at the 3 call sites that need the real instance. Discriminated union/type guard alternatives considered and rejected.
Wasted re-render on mount Low Reference equality check before setSelectedFiles; server files return same f ref from early-return, so no state update fires
Form registered raw FileObject[] for UploadList/UploadDragger Critical Introduced mapExternalValue helper in helper.ts; conversion now happens before useRegisterFormField so form always receives FileType[]
UploadItemSyncValidation missing from UploadList/UploadDragger High Added defaultValidations: [Validations.UploadItemSyncValidation] to both components' useRegisterFormField calls
Internal fields leaking into form submit data Medium toFormValue helper strips download, addedByValue, and request before onFormFieldValueUpdate and external onChange
Tests for value prop N/A 11 tests for UploadDragger, 11 for UploadList, 6 for UploadInput; Form tests for submit data correctness and RequiredUploadedFile validation across all 3 components

Type of Change

  • 🆕 New Component
  • ✨ Feature / Enhancement
  • 🐛 Bug Fix
  • 💥 Breaking Change
  • 📦 Build / Dependency / Docs Update
  • 🧹 Code Refactoring

Screenshots / Preview

Screenshot 2026-06-18 at 11 28 15

Checklist

  • Self-reviewed, no leftover logs or debug code
  • Uses design tokens — no hardcoded style values
  • Accessible (keyboard nav, ARIA, contrast)
  • Tests added/updated and passing
  • Storybook story added/updated

How to Test

const files: FileObject[] = [
    {
      id: "1",
      name: "file1.png",
      type: "image/png",
      size: 1241234,
      onDownloadClick: () => window.open("https://picsum.photos/200/300", "_blank"),
    },
    {
      id: "2",
      name: "file2.png",
      type: "image/png",
      size: 545242,
      onDownloadClick: () => window.open("https://picsum.photos/200/300", "_blank"),
    },
    {
      id: "3",
      name: "file3.png",
      type: "image/png",
      size: 44325252,
      onDownloadClick: () => window.open("https://picsum.photos/200/300", "_blank"),
    },
  ];

  return (
    <Form onSubmit={console.log} style={{ width: 400, margin: "20 auto" }}>
      <Form.Field name="uploadDragger" label="Upload Dragger" readOnly>
        <UploadDragger uploadRequest={MOCK.uploadRequest} deleteRequest={MOCK.deleteRequest} value={files} maxFile={2} />
      </Form.Field>
      <Form.Field name="uploadList" label="Upload List">
        <UploadList uploadRequest={MOCK.uploadRequest} deleteRequest={MOCK.deleteRequest} value={[files[0]]} maxFile={2} />
      </Form.Field>
      <Form.Field name="uploadList2" label="Upload List Readonly" readOnly>
        <UploadList uploadRequest={MOCK.uploadRequest} deleteRequest={MOCK.deleteRequest} value={files} maxFile={2} />
      </Form.Field>
      <Form.Field name="uploadInput" label="Upload Input">
        <UploadInput uploadRequest={MOCK.uploadRequest} deleteRequest={MOCK.deleteRequest} value={[files[0]]} />
      </Form.Field>
    </Form>
  );

@aktasmehmet aktasmehmet requested a review from a team June 18, 2026 09:24
@aktasmehmet aktasmehmet changed the title value props become functional fix(Upload): value prop is added Jun 18, 2026

@atakanbayrak atakanbayrak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was nothing to wrong with work mechanism's of components with this new feature, there are only few things that I would like to discuss in advance.

Comment thread src/lib/components/Upload/helper.ts
Comment thread src/lib/components/Upload/helper.ts
Comment thread src/lib/components/Upload/UploadDragger/UploadDragger.test.tsx
Comment thread src/lib/components/Upload/UploadDragger/UploadDragger.tsx
Comment thread src/lib/components/Upload/UploadInput/UploadInput.test.tsx
@aktasmehmet aktasmehmet requested review from a team and atakanbayrak June 22, 2026 09:05
@aktasmehmet aktasmehmet merged commit 2f150f3 into main Jun 22, 2026
11 of 12 checks passed
@aktasmehmet aktasmehmet deleted the feature/upload_components_value_implement branch June 22, 2026 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants