Skip to content

Commit 77ad6b9

Browse files
authored
feat(b-modal): add scoped style support when portalled (non-static modal) (bootstrap-vue#3962)
1 parent 0d1961c commit 77ad6b9

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/components/modal/modal.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -987,13 +987,21 @@ export const BModal = /*#__PURE__*/ Vue.extend({
987987
}
988988
backdrop = h(BVTransition, { props: { noFade: this.noFade } }, [backdrop])
989989

990+
// If the parent has a scoped style attribute, and the modal
991+
// is portalled, add the scoped attribute to the modal wrapper
992+
const $parent = this.$parent
993+
const scopeAttrs =
994+
!this.static && $parent && $parent.$options._scopeId
995+
? { [`${[$parent.$options._scopeId]}`]: '' }
996+
: {}
997+
990998
// Assemble modal and backdrop in an outer <div>
991999
return h(
9921000
'div',
9931001
{
9941002
key: `modal-outer-${this._uid}`,
9951003
style: this.modalOuterStyle,
996-
attrs: { ...this.$attrs, id: this.safeId('__BV_modal_outer_') }
1004+
attrs: { ...scopeAttrs, ...this.$attrs, id: this.safeId('__BV_modal_outer_') }
9971005
},
9981006
[modal, backdrop]
9991007
)

0 commit comments

Comments
 (0)