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

Bento: add container to the lightbox 1.0 #33488

Merged
merged 1 commit into from
Mar 25, 2021

Conversation

dvoytenko
Copy link
Contributor

Follow up on #33281 for 1.0 version.

Partial for #31915.
Partial for #31540.

'onBeforeOpen': this.toggle_.bind(this, true),
'onAfterClose': this.toggle_.bind(this, false),
'onBeforeOpen': () => this.beforeOpen_(),
'onAfterOpen': () => this.afterOpen_(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we only need onAfterOpen because the element is not rendered when !mounted? Can we do <ContainWrapper style={mounted && {display: 'none'}}> instead of mounted && <ContainWrapper>?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could do display: none, but the goal was specifically to not render contents when the lightbox is not open to make it more React-style.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To add to this. I generally like the idea that the React component looks more inline with that style. And the cost of an event handler seems not too much of a price to pay?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm also confused why we can't setAsContainer in onBeforeOpen. Shouldn't it handle when the scroller eventually becomes visible?

Maybe we shouldn't be calling onBeforeOpen until it's actually mounted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's due to this call:

const scroller = this.element.shadowRoot.querySelector('[part=scroller]');
this.setAsContainer(scroller);

The lightbox itself is not rendered until it's open and thus <div part="scroller"> is not loaded either. So doing that querySelector will return null. For the container it's important to use the actual element with overflow:auto|scroll for the intersection observer to provide the accurate values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will merge before the long weekend. But we will have another opportunity to discuss this with the sidebar component.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sidebar recently replaced the mounted && <ContainWrapper> with the stylized mounting approach in #33244.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep. Found it as well. And I think that's ok - these components are not exactly the same. Though I'd also like to understand the new sidebar a bit better.

@dvoytenko dvoytenko merged commit f42b1e3 into ampproject:master Mar 25, 2021
@dvoytenko dvoytenko deleted the bento/containers branch March 25, 2021 23:32
rochapablo pushed a commit to rochapablo/amphtml that referenced this pull request Aug 30, 2021
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.

4 participants