Skip to content

Commit

Permalink
fix(TU-21474): Remove overflow on widget close (#677)
Browse files Browse the repository at this point in the history
  • Loading branch information
joycevherck authored Jan 7, 2025
1 parent 00fcba8 commit ee4ddf6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/demo-nextjs/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
/// <reference types="next/navigation-types/compat/navigation" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
5 changes: 5 additions & 0 deletions packages/embed/src/factories/create-widget/create-widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const createWidget = (formId: string, options: WidgetOptions): Widget =>

const { domain, ...widgetOptions } = options
widgetOptions.inlineOnMobile = options.inlineOnMobile || options.fullScreen
const scrollInitialState = document.body.style.overflow

if (!widgetOptions.inlineOnMobile && (widgetOptions.forceTouch || isFullscreen())) {
widgetOptions.displayAsFullScreenModal = true
Expand Down Expand Up @@ -117,6 +118,10 @@ export const createWidget = (formId: string, options: WidgetOptions): Widget =>
container.classList.remove('tf-v1-widget-fullscreen')
container.style.backgroundColor = ''

if (widgetOptions.fullScreen) {
document.body.style.overflow = scrollInitialState
}

if (options.keepSession) {
const overlay = document.createElement('div')
overlay.className = 'tf-v1-widget-iframe-overlay'
Expand Down

0 comments on commit ee4ddf6

Please sign in to comment.