Skip to content

Commit

Permalink
fix(Upload): should hide trigger when limit is reached for Upload.Dra…
Browse files Browse the repository at this point in the history
…gger, close #3951 (#4761)

Co-authored-by: lancely <[email protected]>
  • Loading branch information
2 people authored and eternalsky committed Jul 16, 2024
1 parent b9add16 commit aa82b8f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
33 changes: 30 additions & 3 deletions components/upload/__tests__/index-spec.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import React from 'react';
import ReactDOM from 'react-dom';
import Enzyme, { shallow, mount } from 'enzyme';
import Enzyme, { mount } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import assert from 'power-assert';
import sinon from 'sinon';
import Upload from '../index';
import request from '../runtime/request';
import { func } from '../../util';
import '../style';

Enzyme.configure({ adapter: new Adapter() });

Expand Down Expand Up @@ -187,6 +186,34 @@ describe('Upload', () => {

done();
});
// issue: Shell phone model menu icon should hidde, close #3886
it('should hidden upload Dragger when file length === limit', done => {
const drag = document.createElement('div');
document.body.appendChild(drag);
mount(
<Upload.Dragger
listType="image"
limit={1}
defaultValue={[
{
uid: '0',
name: 'IMG.png',
state: 'done',
url: 'https://img.alicdn.com/tps/TB19O79MVXXXXcZXVXXXXXXXXXX-1024-1024.jpg',
downloadURL:
'https://img.alicdn.com/tps/TB19O79MVXXXXcZXVXXXXXXXXXX-1024-1024.jpg',
imgURL: 'https://img.alicdn.com/tps/TB19O79MVXXXXcZXVXXXXXXXXXX-1024-1024.jpg',
},
]}
/>,
{attachTo: drag}
);
assert(document.querySelectorAll('.next-upload-drag').length === 1);
const uploadInner = document.querySelectorAll('.next-upload-inner');
assert(uploadInner.length === 1 )
assert(uploadInner[0].offsetHeight === 0);
done();
});
});

describe('[behavior] Upload Request', () => {
Expand Down
3 changes: 3 additions & 0 deletions components/upload/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,9 @@
#{$upload-prefix}-dragable {
#{$upload-prefix}-inner {
display: block;
&.#{$css-prefix}hidden {
display: none;
}
}

#{$upload-prefix}-drag {
Expand Down

0 comments on commit aa82b8f

Please sign in to comment.