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

Grid broken if no gutter defined #1343

Open
bvogel opened this issue Mar 12, 2024 · 5 comments
Open

Grid broken if no gutter defined #1343

bvogel opened this issue Mar 12, 2024 · 5 comments

Comments

@bvogel
Copy link

bvogel commented Mar 12, 2024

The following code block in grid.rb will break if no gutter is defined:

      def apply_gutter(options)
        if options.key?(:gutter)
          @gutter = Float(options[:gutter])
          @row_gutter = @gutter
          @column_gutter = @gutter
        else
          @row_gutter = Float(options[:row_gutter])
          @column_gutter = Float(options[:column_gutter])
          @gutter = 0
        end
      end

the commit be66ddd replaced options[:row_gutter].to_f which happily returned 0.0 for nil values with Float(options[:row_gutter]) which will break with TypeError: can't convert nil into Float.

(I expect the same to happen in other places where to_f was replaced with Float())

I'd have considered this breaking change that would have merited a mayor version change.

@afdev82
Copy link

afdev82 commented Mar 19, 2024

I have hit this bug too...
What should be the fix here? Rechange Float() with to_f or check for nil?
I could submit a PR

afdev82 added a commit to adnotam/prawn that referenced this issue Mar 19, 2024
@datanoise
Copy link

We ran into this issue too. It would be nice if it is fixed going forward. It is definitely a breaking change.

@pointlessone
Copy link
Member

@datanoise I second that. It'd be absolutely marvellous if the bug got fixed.

@andreavocado
Copy link

There is a workaround for this with same behaviour. Define the gutter argument with zero:

before:
define_grid(rows: 1, columns: 2)

after:
define_grid(rows: 1, columns: 2, gutter: 0)

@afdev82
Copy link

afdev82 commented Apr 11, 2024

I have already submitted a PR for that.

@datanoise I second that. It'd be absolutely marvellous if the bug got fixed.

afdev82 added a commit to adnotam/prawn that referenced this issue Apr 30, 2024
Prefer fetch for default value

Co-authored-by: André Jährling <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

5 participants