Skip to content

Auto set tooltip for FilterBar headers? #56

Description

@jhult

Should forField attempt to auto add the tooltip/title?

This is tricky because forField accepts HasValue but Component.tooltip is an extension on Component.

Here is an example of how I am currently solving it:

fun Component.tooltip(property: KProperty1<*, *>): Component = tooltip(property.name)
fun Component.tooltip(column: Grid.Column<*>): Component = tooltip(column.key)
private fun Component.tooltip(key: String): Component {
    tooltip = SharedUtil.camelCaseToHumanFriendly(key)
    return this
}

/**
 * Create a [TextField] with a [TextField.valueChangeTimeout] of 600.
 */
fun <BEAN : Any, FILTER : Filter<BEAN>> FilterBar<BEAN, FILTER>.textField(column: Grid.Column<BEAN>): FilterBar.Binding.Builder<BEAN, String, FILTER> {
    val component = TextField().apply {
        // increase filter timeout from default 400 to 600
        // 400 seems a little fast for when someone is typing in a value (in case they pause)
        valueChangeTimeout = 600

        addThemeVariants(TextFieldVariant.LUMO_SMALL)

        tooltip(column)
    }
    return forField(component, column)
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions