R (ver 3.4.1) I am working with DT (ver 0.4) package in shiny (ver 1.0.5) and have a need where I want to prevent the deselection of an already selected row when user clicks on it again. For example in below image if user clicks on row 3 again it should not get deselected. However if user selects a new row then that new row gets selected while the earlier row gets deselected.
I guess what I need is for datatable to completely ignore a click-event on an already selected row.

I tried using shinyjs::onclick as shown below but is not ideal as it seems to "de-select & re-select" the selected row (the blue highlight disappears and reappears when clicked on again) rather than preventing deselection.
library(shiny)
library(DT)
library(shinyjs)
shinyApp(
ui <- shinyUI(
fluidPage(
shinyjs::useShinyjs(),
DTOutput("test")
)
),
server <- shinyServer(function(input, output, session) {
output$test <- renderDT({
datatable(head(iris), selection = 'single')
})
shinyjs::onclick("test",
selectRows(dataTableProxy("test"), selected = input$test_rows_selected)
)
})
)
I was wondering if there was an easy way to do this. Thanks!