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

itemsPerRow may result 0 (starting from rev25.2 ) preventing image to show #676

Closed
bagnus opened this issue Mar 18, 2021 · 3 comments
Closed

Comments

@bagnus
Copy link

bagnus commented Mar 18, 2021

Describe the bug

Since rev 25.1 in some situations itemsPerRow gives 0 preventing the file to be shown.
That's because itemsPerRow is now the return value of the function getItemsPerRow = function(horizontalSpace, itemWidth).
If horizontalSpace < itemWidth the return is = 0 and the image is not shown without any warning.

Logs

To Reproduce

In my case the pond element is a fieldset with all elements inside having a margin of 2 pixels each side.
When loading files, I have 1 file for any row.
Until 25.1 itemsPerRow was always = 1.
With 25.2 itemsPerRow is always = 0.

Looking at HTML generated by filepond with a debugger, in my case:
horizontalSpace = 940
itemWidth = 944 (940 + 4 pixels for margins)

And in this situation the function
var getItemsPerRow = function(horizontalSpace, itemWidth) {
// add one pixel leeway, when using percentages for item width total items can be 1.99 per row
return Math.floor((horizontalSpace + 1) / itemWidth);
};

gives zero.

Once understood this, I solved my problem adding a CSS that shorted the file items, ex :
.filepond--item { width: 920px;}

Previously (Until 25.1 ) no filepond--item css was needed.

Expected behavior

If the computation of itemsPerRow is always done with at least one file to show, then getItemsPerRow() would return always a value >= 1.

Or if zero is the correct return value of getItemsPerRow(), perhaps would be better try to draw anyway the image.
In this way the rendering would show space problem and programmer would add/correct the related css.

Stacktraces

Information about your project:

  • Crome 86.01.1 64 bits
  • MacOS 10 .14.6
  • FilePond version: problem started with 52.2

Additional context

greetings
Andrea

@rikschennink
Copy link
Collaborator

Fixing now!

@rikschennink
Copy link
Collaborator

Should be fixed in 4.26.0

@rikschennink
Copy link
Collaborator

Closed because inactive.

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

No branches or pull requests

2 participants