Skip to content

feat(components): [affix] support append-to and teleported#23053

Merged
btea merged 10 commits into
element-plus:devfrom
micaiguai:feat/affix-append-to-body
Dec 15, 2025
Merged

feat(components): [affix] support append-to and teleported#23053
btea merged 10 commits into
element-plus:devfrom
micaiguai:feat/affix-append-to-body

Conversation

@micaiguai
Copy link
Copy Markdown
Contributor

@micaiguai micaiguai commented Dec 9, 2025

Close #22301

Problem

position: fixed breaks when a parent has transform, filter, perspective, etc.

MDN Reference: https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/position#fixed_positioning.

Solution

Support appendToBody prop.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 9, 2025

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Dec 9, 2025

Open in StackBlitz

pnpm add https://pkg.pr.new/element-plus/element-plus@23053
npm i https://pkg.pr.new/element-plus/element-plus@23053
yarn add https://pkg.pr.new/element-plus/[email protected]

commit: 5ff86e4

@micaiguai micaiguai changed the title feat(components): [affix] implement append-to-body feat(components): [affix] support append-to-body prop Dec 9, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 9, 2025

🧪 Playground Preview: https://element-plus.run/?pr=23053
Please comment the example via this playground if needed.

@micaiguai
Copy link
Copy Markdown
Contributor Author

Before

After

@btea
Copy link
Copy Markdown
Member

btea commented Dec 11, 2025

We can refer to other components and add teleported and append-to props. for example https://element-plus.org/en-US/component/select

@micaiguai
Copy link
Copy Markdown
Contributor Author

We can refer to other components and add teleported and append-to props. for example https://element-plus.org/en-US/component/select

Thanks for your suggestions. I've fixed it.

@micaiguai
Copy link
Copy Markdown
Contributor Author

The latest Playground Case

Copy link
Copy Markdown
Member

@rzzf rzzf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution! I have a suggestion.

Comment thread packages/components/affix/src/affix.ts Outdated
Comment thread packages/components/affix/src/affix.vue Outdated
@micaiguai
Copy link
Copy Markdown
Contributor Author

Thanks for your contribution! I have a suggestion.

Thanks.

Comment thread packages/components/affix/src/affix.vue Outdated
@micaiguai micaiguai changed the title feat(components): [affix] support append-to-body prop feat(components): [affix] support append-to and teleported Dec 12, 2025
@github-actions github-actions Bot removed the CommitMessage::Unqualified Unqualified commit message label Dec 12, 2025
Copy link
Copy Markdown
Member

@rzzf rzzf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

Comment thread packages/components/affix/src/affix.vue Outdated
Comment thread docs/en-US/component/affix.md Outdated
Comment thread docs/en-US/component/affix.md Outdated
@btea btea merged commit b171632 into element-plus:dev Dec 15, 2025
14 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

@micaiguai Thanks for your contribution! ❤️

@element-bot element-bot mentioned this pull request Dec 19, 2025
3 tasks
@TQUAUQT
Copy link
Copy Markdown

TQUAUQT commented Dec 25, 2025

Sir, may I ask, when the affix component is activated and switches between fixed and non-fixed states, it will trigger the unloading and re-mounting of the component. I noticed in the code of Element-plus that teleported has encapsulated an additional layer and uses v-if for switching. In fact, teleported has a disabled attribute for switching purposes. When using the affix component for fixed business with state, the state switching triggers the component's lifecycle again. Perhaps this is not what I expected. I would like to ask if there are any other considerations behind this design of teleported?

@micaiguai
Copy link
Copy Markdown
Contributor Author

Sir, may I ask, when the affix component is activated and switches between fixed and non-fixed states, it will trigger the unloading and re-mounting of the component. I noticed in the code of Element-plus that teleported has encapsulated an additional layer and uses v-if for switching. In fact, teleported has a disabled attribute for switching purposes. When using the affix component for fixed business with state, the state switching triggers the component's lifecycle again. Perhaps this is not what I expected. I would like to ask if there are any other considerations behind this design of teleported?

Thanks for pointing this out! I've solved this problem.

Related: #23219 (comment)

@TQUAUQT
Copy link
Copy Markdown

TQUAUQT commented Dec 30, 2025

Thank you very much, but I have encountered another issue. When scaling the screen with the push pin fixed, the width and height of the push pin will not change with the screen scaling, resulting in a horizontal scrollbar. Boss, can you help me take a look at this problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Component] [affix] el-affix use wrong fixed when meet transform

4 participants