Interactive legend not showing when hovering in the center of polygons in an R Plotly map. Only appears over the outline (shape)

Someone great gave me this solution on another forum. Copy the code below and when you print the graph you add the function.
library(tidyverse)
library(plotly)
library(sf)

fixer <- function(gp) {
lapply(1:length(gp$x$data), (m) {
gp$x$data[[m]]$hoveron <<- "fills" # hover on the fill, not line
if(length(gp$x$data[[m]]$text > 1)) {
gp$x$data[[m]]$text <<- gp$x$data[[m]]$text[1] # only one tooltip per county
}
})
gp
}

ggplotly(g, tooltip = "text") %>% fixer() # call the UDF to change tooltips