Skip to content

Pass ranges directly to optionalSliderInput and remove min, max, and step arguments #101

Description

@donyunardi

Maybe we should investigate if we could just pass the ranges directly to optionalSliderInput and remove min, max, and step arguments to optimize our code.

teal.slice/R/FilterState.R

Lines 1381 to 1403 in a449203

ui = function(id) {
ns <- NS(id)
pretty_range_inputs <- private$get_pretty_range_inputs(private$choices)
fluidRow(
div(
class = "filterPlotOverlayRange",
plotOutput(ns("plot"), height = "100%")
),
teal.widgets::optionalSliderInput(
inputId = ns("selection"),
label = NULL,
min = pretty_range_inputs["min"],
max = pretty_range_inputs["max"],
# on filter init without predefined value select "pretty" (wider) range
value = isolate({
if (identical(private$choices, self$get_selected())) {
pretty_range_inputs[c("min", "max")]
} else {
self$get_selected()
}
}),
width = "100%",
step = pretty_range_inputs["step"]

I'll make a new issue so we can look into this.

Originally posted by @donyunardi in #98 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions