Skip to content

Commit

Permalink
refactor: remove default indexBarOffset to allow CSS variable fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
tiantiancheng committed Feb 20, 2025
1 parent 095a566 commit e6f05ad
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
1 change: 0 additions & 1 deletion docs/zh-CN/components/list.md
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,6 @@ order: 56
"type": "list",
"source": "$rows",
"showIndexBar": true,
"indexBarOffset": 60,
"listItem": {
"title": "${name}",
"subTitle": "${title}",
Expand Down
4 changes: 2 additions & 2 deletions packages/amis-editor/src/plugin/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class ListPlugin extends BasePlugin {
scaffold = {
type: 'list',
showIndexBar: false,
indexBarOffset: 60,
indexBarOffset: 0,
listItem: {
body: [
{
Expand Down Expand Up @@ -177,7 +177,7 @@ export class ListPlugin extends BasePlugin {
type: 'input-number',
name: 'indexBarOffset',
label: '顶部偏移量',
value: 60,
value: 0,
min: 0,
max: 200,
unit: 'px',
Expand Down
11 changes: 7 additions & 4 deletions packages/amis/src/renderers/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,7 @@ export default class List extends React.Component<
selectable: false,
headerClassName: '',
footerClassName: '',
affixHeader: true,
indexBarOffset: 0
affixHeader: true
};

dragTip?: HTMLElement;
Expand Down Expand Up @@ -1686,7 +1685,6 @@ export class ListItem extends React.Component<ListItemProps> {
const title = filter(titleTpl, data);
const subTitle = filter(subTitleTpl, data);
const desc = filter(descTpl, data);

return (
<div
data-index={itemIndex}
Expand All @@ -1698,7 +1696,12 @@ export class ListItem extends React.Component<ListItemProps> {
},
className
)}
style={{scrollMarginTop: `${indexBarOffset}px`}}
style={{
scrollMarginTop:
indexBarOffset !== undefined
? `${indexBarOffset}px`
: 'var(--affix-offset-top)'
}}
>
{this.renderLeft()}
{this.renderRight()}
Expand Down

0 comments on commit e6f05ad

Please sign in to comment.