Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(material/tabs): add the ability to keep content inside the DOM while off-screen #20393

Merged
merged 1 commit into from
Jan 27, 2022

Conversation

crisbeto
Copy link
Member

Adds the preserveContent input which allows consumers to opt into keeping the content of off-screen tabs inside the DOM. This is useful primarily for edge cases like iframes and videos where removing the element from the DOM will cause it to reload.

One gotcha here is that we have to set visibility: hidden on the off-screen content so that users can't tab into it.

Fixes #19480.

@crisbeto crisbeto added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent target: minor This PR is targeted for the next minor release labels Aug 22, 2020
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Aug 22, 2020
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

I can't think of anything strictly better than preserveContent. "persist" is an alternative, but I don't see much of a distinction between them.

Could you update the docs with a section / example for this?

@crisbeto
Copy link
Member Author

crisbeto commented Sep 7, 2020

I've added docs and a live example @jelbourn. Can you take another look?

Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

LGTM

@jelbourn jelbourn added the action: merge The PR is ready for merge by the caretaker label Sep 17, 2020
@crisbeto crisbeto changed the title feat(tabs): add the ability to keep content inside the DOM while off-screen feat(material/tabs): add the ability to keep content inside the DOM while off-screen Nov 9, 2020
@crisbeto crisbeto force-pushed the 19480/tabs-preserve-content branch from a79ea64 to 51eee12 Compare April 18, 2021 12:00
@crisbeto crisbeto force-pushed the 19480/tabs-preserve-content branch from 51eee12 to 4bfb174 Compare April 25, 2021 13:29
@crisbeto crisbeto requested a review from a team as a code owner August 20, 2021 19:47
@josephperrott josephperrott removed the request for review from a team August 20, 2021 20:07
@calvinjc
Copy link

What is preventing this PR from being merged? This fix was labeled "merge ready" a year ago. Please merge or provide an update.

@jelbourn
Copy link
Member

Looks like there was just one screenshot diff affecting this.

@crisbeto I coincidentally got two requests related to this feature from Googlers this week, so I'll try to push it forward. However, what do you think of changing the input name to preserveAfterLoad to be slightly more explicit?

@crisbeto
Copy link
Member Author

crisbeto commented Sep 17, 2021

I'm not super attached to the name, but having the load in there sounds to me like we're the ones doing the loading.

@kseamon
Copy link
Collaborator

kseamon commented Sep 17, 2021

Pretty sure this will work fine but please also include a unit test with lazy-rendered tab contents - we'd want it to retain it's lazy rendering but keep the rendered content alive after tabbing away.

@jelbourn
Copy link
Member

@crisbeto fair enough, I don't feel strongly either way

@luiz-shonen
Copy link

Hello! I'm needing this feature a lot. Is it going to be merged?

@calvinjc
Copy link

@jelbourn, @crisbeto it looks like there was an attempt to push this forward after my last comment, but it looks like it has stalled again. There hasn't been any movement or new comments in a few weeks. It sounds like this would help a lot of people. Can you please get this merged in?

@jelbourn
Copy link
Member

@crisbeto this might be a good first issue for you to try to land directly in Google

@DaleMatthews
Copy link

This is one of the bigger lacking features that most popular libraries' tab components have. It is essential when working with iframe content. Could this get merged? Thanks in advance ng team!!

@crisbeto crisbeto force-pushed the 19480/tabs-preserve-content branch 2 times, most recently from ca547a6 to 2482274 Compare October 28, 2021 12:17
@btvanhooser
Copy link

Looks like this is good to go and my team would really like this. Are there plans to merge this?

@kseamon
Copy link
Collaborator

kseamon commented Dec 15, 2021

Per our discovery with visibility getting overridden inside of expansion panels, please make sure to use

visibility: hidden !important

@crisbeto
Copy link
Member Author

Pushed a similar fix to the expansion panel that adds display: none once the tab is hidden.

@PandaCodeAng
Copy link

i also need this feature thank you

@andrewseguin andrewseguin removed the cla: yes PR author has agreed to Google's Contributor License Agreement label Dec 28, 2021
@wagnermaciel
Copy link
Contributor

@crisbeto This had some conflicts with another PR that I merged in earlier today

@crisbeto
Copy link
Member Author

crisbeto commented Jan 8, 2022

I've rebased the PR.

@ddolson2541
Copy link

I'm hoping this is close to being merged? Without the ability to retain an iframe in the DOM, my project simply won't work with tabs. Thanks.

…hile off-screen

Adds the `preserveContent` input which allows consumers to opt into keeping the
content of off-screen tabs inside the DOM. This is useful primarily for edge cases like
iframes and videos where removing the element from the DOM will cause it to reload.

One gotcha here is that we have to set `visibility: hidden` on the off-screen content so that users can't tab into it.

Fixes angular#19480.
@crisbeto crisbeto merged commit c3188c8 into angular:master Jan 27, 2022
crisbeto added a commit to crisbeto/material2 that referenced this pull request Jan 27, 2022
@crisbeto crisbeto mentioned this pull request Jan 27, 2022
crisbeto added a commit that referenced this pull request Jan 27, 2022
crisbeto added a commit to crisbeto/material2 that referenced this pull request Jan 28, 2022
…hile off-screen

**Note:** this is a resubmit of angular#20393 with a minor adjustment in the animation config to fix the issue that caused it to be reverted due to an error in Firefox tests.

Adds the `preserveContent` input which allows consumers to opt into keeping the
content of off-screen tabs inside the DOM. This is useful primarily for edge cases like
iframes and videos where removing the element from the DOM will cause it to reload.

One gotcha here is that we have to set `visibility: hidden` on the off-screen content so that users can't tab into it.

Fixes angular#19480.
crisbeto added a commit that referenced this pull request Jan 28, 2022
…hile off-screen (#24299)

**Note:** this is a resubmit of #20393 with a minor adjustment in the animation config to fix the issue that caused it to be reverted due to an error in Firefox tests.

Adds the `preserveContent` input which allows consumers to opt into keeping the
content of off-screen tabs inside the DOM. This is useful primarily for edge cases like
iframes and videos where removing the element from the DOM will cause it to reload.

One gotcha here is that we have to set `visibility: hidden` on the off-screen content so that users can't tab into it.

Fixes #19480.
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Feb 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support hiding/showing tabs instead of destroying/creating