Skip to content

Commit

Permalink
fix: 修复AntdMenu在AntdSider内部时受折叠切换状态时显示异常的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
CNFeffery committed Jan 10, 2025
1 parent a90c5b2 commit 237ac23
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 5 deletions.
2 changes: 1 addition & 1 deletion feffery_antd_components/AntdMenu.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class AntdMenu(Component):
- popupContainer (a value equal to: 'parent', 'body'; default 'body'):
菜单展开层锚定策略,可选项有`'parent'`、`'body'` 默认值:`'body'`.
- inlineCollapsed (boolean; default False):
- inlineCollapsed (boolean; optional):
当前菜单是否折叠,仅inline模式下有效 默认值:`False`.
- inlineIndent (number; default 24):
Expand Down
10 changes: 7 additions & 3 deletions feffery_antd_components/AntdTreeSelect.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ class AntdTreeSelect(Component):
- defaultValue (string | number | list of string | numbers; optional):
初始化已选值.
- maxCount (number; optional):
当`multiple=True`时,可选中的最大数量
如果`showCheckedStrategy='show-all'`且`treeCheckStrictly=False`,或者`showCheckedStrategy='show-parent'`,则`maxCount`无效.
- maxTagCount (number | a value equal to: 'responsive'; optional):
当`multiple=True`时,已选值tag展示的最大数量.
Expand Down Expand Up @@ -190,10 +194,10 @@ class AntdTreeSelect(Component):
_namespace = 'feffery_antd_components'
_type = 'AntdTreeSelect'
@_explicitize_args
def __init__(self, id=Component.UNDEFINED, key=Component.UNDEFINED, style=Component.UNDEFINED, className=Component.UNDEFINED, popupClassName=Component.UNDEFINED, name=Component.UNDEFINED, locale=Component.UNDEFINED, treeDataMode=Component.UNDEFINED, treeData=Component.REQUIRED, treeNodeKeyToTitle=Component.UNDEFINED, disabled=Component.UNDEFINED, size=Component.UNDEFINED, bordered=Component.UNDEFINED, variant=Component.UNDEFINED, placeholder=Component.UNDEFINED, placement=Component.UNDEFINED, treeLine=Component.UNDEFINED, value=Component.UNDEFINED, defaultValue=Component.UNDEFINED, maxTagCount=Component.UNDEFINED, maxTagPlaceholder=Component.UNDEFINED, maxTagTextLength=Component.UNDEFINED, listHeight=Component.UNDEFINED, multiple=Component.UNDEFINED, suffixIcon=Component.UNDEFINED, switcherIcon=Component.UNDEFINED, treeCheckable=Component.UNDEFINED, treeCheckStrictly=Component.UNDEFINED, treeDefaultExpandAll=Component.UNDEFINED, treeDefaultExpandedKeys=Component.UNDEFINED, treeExpandedKeys=Component.UNDEFINED, virtual=Component.UNDEFINED, status=Component.UNDEFINED, allowClear=Component.UNDEFINED, treeNodeFilterProp=Component.UNDEFINED, treeNodeFilterMode=Component.UNDEFINED, autoClearSearchValue=Component.UNDEFINED, showCheckedStrategy=Component.UNDEFINED, dropdownBefore=Component.UNDEFINED, dropdownAfter=Component.UNDEFINED, prefix=Component.UNDEFINED, readOnly=Component.UNDEFINED, enableAsyncLoad=Component.UNDEFINED, loadingNode=Component.UNDEFINED, popupContainer=Component.UNDEFINED, batchPropsNames=Component.UNDEFINED, batchPropsValues=Component.UNDEFINED, loading_state=Component.UNDEFINED, persistence=Component.UNDEFINED, persisted_props=Component.UNDEFINED, persistence_type=Component.UNDEFINED, **kwargs):
self._prop_names = ['id', 'key', 'style', 'className', 'popupClassName', 'name', 'locale', 'treeDataMode', 'treeData', 'treeNodeKeyToTitle', 'disabled', 'size', 'bordered', 'variant', 'placeholder', 'placement', 'treeLine', 'value', 'defaultValue', 'maxTagCount', 'maxTagPlaceholder', 'maxTagTextLength', 'listHeight', 'multiple', 'suffixIcon', 'switcherIcon', 'treeCheckable', 'treeCheckStrictly', 'treeDefaultExpandAll', 'treeDefaultExpandedKeys', 'treeExpandedKeys', 'virtual', 'status', 'allowClear', 'treeNodeFilterProp', 'treeNodeFilterMode', 'autoClearSearchValue', 'showCheckedStrategy', 'dropdownBefore', 'dropdownAfter', 'prefix', 'readOnly', 'enableAsyncLoad', 'loadingNode', 'popupContainer', 'batchPropsNames', 'batchPropsValues', 'data-*', 'aria-*', 'loading_state', 'persistence', 'persisted_props', 'persistence_type']
def __init__(self, id=Component.UNDEFINED, key=Component.UNDEFINED, style=Component.UNDEFINED, className=Component.UNDEFINED, popupClassName=Component.UNDEFINED, name=Component.UNDEFINED, locale=Component.UNDEFINED, treeDataMode=Component.UNDEFINED, treeData=Component.REQUIRED, treeNodeKeyToTitle=Component.UNDEFINED, disabled=Component.UNDEFINED, size=Component.UNDEFINED, bordered=Component.UNDEFINED, variant=Component.UNDEFINED, placeholder=Component.UNDEFINED, placement=Component.UNDEFINED, treeLine=Component.UNDEFINED, value=Component.UNDEFINED, defaultValue=Component.UNDEFINED, maxCount=Component.UNDEFINED, maxTagCount=Component.UNDEFINED, maxTagPlaceholder=Component.UNDEFINED, maxTagTextLength=Component.UNDEFINED, listHeight=Component.UNDEFINED, multiple=Component.UNDEFINED, suffixIcon=Component.UNDEFINED, switcherIcon=Component.UNDEFINED, treeCheckable=Component.UNDEFINED, treeCheckStrictly=Component.UNDEFINED, treeDefaultExpandAll=Component.UNDEFINED, treeDefaultExpandedKeys=Component.UNDEFINED, treeExpandedKeys=Component.UNDEFINED, virtual=Component.UNDEFINED, status=Component.UNDEFINED, allowClear=Component.UNDEFINED, treeNodeFilterProp=Component.UNDEFINED, treeNodeFilterMode=Component.UNDEFINED, autoClearSearchValue=Component.UNDEFINED, showCheckedStrategy=Component.UNDEFINED, dropdownBefore=Component.UNDEFINED, dropdownAfter=Component.UNDEFINED, prefix=Component.UNDEFINED, readOnly=Component.UNDEFINED, enableAsyncLoad=Component.UNDEFINED, loadingNode=Component.UNDEFINED, popupContainer=Component.UNDEFINED, batchPropsNames=Component.UNDEFINED, batchPropsValues=Component.UNDEFINED, loading_state=Component.UNDEFINED, persistence=Component.UNDEFINED, persisted_props=Component.UNDEFINED, persistence_type=Component.UNDEFINED, **kwargs):
self._prop_names = ['id', 'key', 'style', 'className', 'popupClassName', 'name', 'locale', 'treeDataMode', 'treeData', 'treeNodeKeyToTitle', 'disabled', 'size', 'bordered', 'variant', 'placeholder', 'placement', 'treeLine', 'value', 'defaultValue', 'maxCount', 'maxTagCount', 'maxTagPlaceholder', 'maxTagTextLength', 'listHeight', 'multiple', 'suffixIcon', 'switcherIcon', 'treeCheckable', 'treeCheckStrictly', 'treeDefaultExpandAll', 'treeDefaultExpandedKeys', 'treeExpandedKeys', 'virtual', 'status', 'allowClear', 'treeNodeFilterProp', 'treeNodeFilterMode', 'autoClearSearchValue', 'showCheckedStrategy', 'dropdownBefore', 'dropdownAfter', 'prefix', 'readOnly', 'enableAsyncLoad', 'loadingNode', 'popupContainer', 'batchPropsNames', 'batchPropsValues', 'data-*', 'aria-*', 'loading_state', 'persistence', 'persisted_props', 'persistence_type']
self._valid_wildcard_attributes = ['data-', 'aria-']
self.available_properties = ['id', 'key', 'style', 'className', 'popupClassName', 'name', 'locale', 'treeDataMode', 'treeData', 'treeNodeKeyToTitle', 'disabled', 'size', 'bordered', 'variant', 'placeholder', 'placement', 'treeLine', 'value', 'defaultValue', 'maxTagCount', 'maxTagPlaceholder', 'maxTagTextLength', 'listHeight', 'multiple', 'suffixIcon', 'switcherIcon', 'treeCheckable', 'treeCheckStrictly', 'treeDefaultExpandAll', 'treeDefaultExpandedKeys', 'treeExpandedKeys', 'virtual', 'status', 'allowClear', 'treeNodeFilterProp', 'treeNodeFilterMode', 'autoClearSearchValue', 'showCheckedStrategy', 'dropdownBefore', 'dropdownAfter', 'prefix', 'readOnly', 'enableAsyncLoad', 'loadingNode', 'popupContainer', 'batchPropsNames', 'batchPropsValues', 'data-*', 'aria-*', 'loading_state', 'persistence', 'persisted_props', 'persistence_type']
self.available_properties = ['id', 'key', 'style', 'className', 'popupClassName', 'name', 'locale', 'treeDataMode', 'treeData', 'treeNodeKeyToTitle', 'disabled', 'size', 'bordered', 'variant', 'placeholder', 'placement', 'treeLine', 'value', 'defaultValue', 'maxCount', 'maxTagCount', 'maxTagPlaceholder', 'maxTagTextLength', 'listHeight', 'multiple', 'suffixIcon', 'switcherIcon', 'treeCheckable', 'treeCheckStrictly', 'treeDefaultExpandAll', 'treeDefaultExpandedKeys', 'treeExpandedKeys', 'virtual', 'status', 'allowClear', 'treeNodeFilterProp', 'treeNodeFilterMode', 'autoClearSearchValue', 'showCheckedStrategy', 'dropdownBefore', 'dropdownAfter', 'prefix', 'readOnly', 'enableAsyncLoad', 'loadingNode', 'popupContainer', 'batchPropsNames', 'batchPropsValues', 'data-*', 'aria-*', 'loading_state', 'persistence', 'persisted_props', 'persistence_type']
self.available_wildcard_properties = ['data-', 'aria-']
_explicit_args = kwargs.pop('_explicit_args')
_locals = locals()
Expand Down
1 change: 0 additions & 1 deletion src/lib/components/navigation/AntdMenu.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,6 @@ AntdMenu.defaultProps = {
onlyExpandCurrentSubMenu: false,
renderCollapsedButton: false,
popupContainer: 'body',
inlineCollapsed: false,
inlineIndent: 24,
triggerSubMenuAction: 'hover',
persisted_props: ['currentKey', 'openKeys'],
Expand Down
71 changes: 71 additions & 0 deletions tests/navigation/AntdMenu/fix_with_sider.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
if True:
import sys

sys.path.append('../../../')
from dash import Dash
import feffery_antd_components as fac

app = Dash(__name__)

app.layout = fac.AntdLayout(
[
fac.AntdSider(
[
fac.AntdMenu(
menuItems=[
{
'component': 'Item',
'props': {
'key': f'图标{icon}',
'title': f'图标{icon}',
'icon': icon,
},
}
for icon in [
'antd-home',
'antd-cloud-upload',
'antd-bar-chart',
'antd-pie-chart',
'antd-dot-chart',
'antd-line-chart',
'antd-apartment',
'antd-app-store',
'antd-app-store-add',
'antd-bell',
'antd-calculator',
'antd-calendar',
'antd-database',
'antd-history',
]
],
mode='inline',
style={
'height': '100%',
'width': '100%',
'overflow': 'hidden auto',
},
)
],
collapsible=True,
collapsedWidth=60,
style={'backgroundColor': 'rgb(240, 242, 245)'},
),
fac.AntdContent(
fac.AntdCenter(
fac.AntdTitle(
'内容区示例',
level=2,
style={'margin': '0'},
),
style={
'height': '100%',
},
),
style={'backgroundColor': 'white'},
),
],
style={'height': '100vh'},
)

if __name__ == '__main__':
app.run(debug=True)

0 comments on commit 237ac23

Please sign in to comment.