CNFeffery / feffery-antd-components

Dash + Ant Design = 😍
http://fac.feffery.tech
MIT License
321 stars 25 forks source link

searchKeyword in AntdTree looks sensitive case when the string contains a number #130

Closed joyceraraujo closed 10 months ago

joyceraraujo commented 11 months ago

Hello, I am using an AntdInput in combination with an AntdTree to implement tree search functionality. I've noticed that the search is case-sensitive when the string contains a number. For instance, searching for 'a2' does not display the title 'A2.' I need to explicitly type 'A2' to find the title. Do you know how can I address this issue?". Thank you for your support.

CNFeffery commented 10 months ago

@joyceraraujo Update fac to 0.3.0b5 version, then use the new parameter caseSensitive, follow the demo below:

import dash
from dash import html
import feffery_antd_components as fac
from dash.dependencies import Input, Output

app = dash.Dash(__name__)

app.layout = html.Div(
    [
        fac.AntdSpace(
            [
                fac.AntdFormItem(
                    fac.AntdSwitch(
                        id='case-sensitive',
                        checked=True
                    ),
                    label='caseSensitive'
                ),
                fac.AntdInput(
                    id='keyword',
                    autoComplete='off',
                    allowClear=True
                ),
                fac.AntdTree(
                    id='demo-tree',
                    treeData=[
                        {
                            'key': 'root',
                            'title': 'root',
                            'children': [
                                {
                                    'key': value,
                                    'title': value
                                }
                                for value in [
                                    'gdp',
                                    'GDP',
                                    'cpi',
                                    'CPI'
                                ]
                            ]
                        }
                    ],
                    defaultExpandAll=True
                )
            ],
            direction='vertical'
        )
    ],
    style={
        'padding': '50px 100px'
    }
)

@app.callback(
    [Output('demo-tree', 'searchKeyword'),
     Output('demo-tree', 'caseSensitive')],
    [Input('keyword', 'value'),
     Input('case-sensitive', 'checked')]
)
def set_search_keyword(keyword, checked):
    return keyword, checked

if __name__ == '__main__':
    app.run(debug=True)
joyceraraujo commented 10 months ago

Perfect, thank you a lot.