adding isolate() in this line :
selected <- ifelse(input$inSelect %in% x, input$inSelect, tail(x, 1))
so it looks like this:
selected <- ifelse(isolate(input$inSelect) %in% x, isolate(input$inSelect), tail(x, 1))
appears to solve the problem