Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NUpload does not limit to one file when not in multiple mode #363

Closed
rhengles opened this issue Jul 2, 2021 · 1 comment · Fixed by #369
Closed

NUpload does not limit to one file when not in multiple mode #363

rhengles opened this issue Jul 2, 2021 · 1 comment · Fixed by #369

Comments

@rhengles
Copy link
Contributor

rhengles commented Jul 2, 2021

TuSimple/naive-ui version (版本)

2.15.2

Vue version (Vue 版本)

3.1.4

Browser and its version (浏览器及其版本)

Microsoft Edge Version 91.0.864.59 (64 bits)

System and its version (系统及其版本)

Windows 10 with WSL2

Node version (Node 版本)

Reappearance link (重现链接)

https://github.com/arijs/naiveui-issue-nupload-single-file

Reappearance steps (重现步骤)

Just add <n-upload> with <n-upload-dragger> inside, then select one file and THEN select another file. Each step only allow one file, but when you select the second file, the first does not go away.

Expected results (期望的结果)

Only allow to select one file, wether they are selected at the same time or added later.

Actual results (实际的结果)

It allows multiple files to be selected, even when using <n-upload :multiple="false">

Remarks (补充说明)

@rhengles
Copy link
Contributor Author

rhengles commented Jul 2, 2021

Workaround:

<n-upload
	:file-list="uploadRef"
	@update:file-list="handleUploadRefChange"
>
const uploadRef = ref()

function handleUploadRefChange(fileList) {
	const length = fileList?.length || 0
	if (length > 1) {
		fileList = [fileList[length - 1]]
	}
	uploadRef.value = fileList
}

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 a pull request may close this issue.

2 participants