sinkovit / Spatial-ecology

Space use software deployed in the Spatial Ecology Gateway
MIT License
2 stars 0 forks source link

UI weirdness #31

Closed monaw closed 1 year ago

monaw commented 1 year ago

Bob gets a crash when he deletes the value from the cell size parameter in the UI but Mona doesn't get the crash for the same action!

Here's the crash output: Screen Shot 2022-10-12 at 4 41 58 PM

And here's app.R line 230 from dev branch 0b1b5185351a588af25ecdbf0e469f77a4003346 Screen Shot 2022-10-12 at 4 39 09 PM

sinkovit commented 1 year ago

I was able to fix the bug by adding an as.numeric() test on the cell size. Specifically, replacing this ...

if (! isEmpty (gps$original) && input$cellsize >= 1)

... with this ...

if (! isEmpty (gps$original) && is.numeric(input$cellsize) && input$cellsize >= 1)

After making this change, the shiny app works fine and actually prohibits me from entering something that's not a number.

Regarding the source of the error, I'm wondering if this is a Windows vs. Mac problem (I'm on a Mac).

sinkovit commented 1 year ago

On a related note, I noticed that you're only testing the cell size before enabling the run button (runx). We should probably add tests to make sure that the other values are valid

sinkovit commented 1 year ago

Finally, since R does short circuiting (see https://r-critique.com/short-circuit-evaluation), I would recommend putting the is.numeric() tests before the comparisons.

sinkovit commented 1 year ago

Implemented changes and committed to the dev branch

sinkovit commented 1 year ago

Closed