baidu / baidu/amis

nav 控件支持在 expandIcon 中获取菜单的当前状态(例如 isOpen)

Open
#8,178 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
TypeScript
Stars
18.9k
Forks
2.7k
PR merge metrics
No merged PRs in 30d

Description

#### 是否关联于某个问题吗:
自定义expandIcon时,可以用表达式区分菜单的展开状态,例如:
企业微信截图_415a8af9-d4a1-458c-9102-f8380be71157

企业微信截图_bc254b6b-6103-4c47-8866-f4ec99bd2e7e

#### 预期的解决方案:
目前传入参数没有效果
```json
{
"type": "nav",
"stacked": true,
"expandIcon": {
"type": "icon",
"icon": "${isOpen? 'far fa-angle-down':'far fa-angle-right'}"
},
}
```

#### 任何附加信息:
相关源码
https://github.com/baidu/amis/blob/master/packages/amis-ui/src/components/menu/index.tsx#L534

可用参数包括:
```js
renderExpandIcon(ctx: {
isSelected?: boolean;
isOpen?: boolean;
isSubMenu?: boolean;
disabled?: boolean;
[propName: string]: any;
})
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at packages/amis-ui/src/components/menu/index.tsx around the referenced line and trace how renderExpandIcon receives its context. Verify how the nav component renders expandIcon expressions, then make the requested current menu state available so isOpen can distinguish expanded and collapsed menus. Confirm the example configuration produces the corresponding icons.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.