mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-08-14 00:26:21 +00:00
Fix: handle overflowing dropdowns on mobile (#7758)
See https://github.com/ng-bootstrap/ng-bootstrap/pull/4760
This commit is contained in:
24
src-ui/src/app/utils/popper-options.spec.ts
Normal file
24
src-ui/src/app/utils/popper-options.spec.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { popperOptionsReenablePreventOverflow } from './popper-options'
|
||||
import { Options } from '@popperjs/core'
|
||||
|
||||
describe('popperOptionsReenablePreventOverflow', () => {
|
||||
it('should return the config without the empty fun preventOverflow, add padding to other', () => {
|
||||
const config: Partial<Options> = {
|
||||
modifiers: [
|
||||
{ name: 'preventOverflow', fn: function () {} },
|
||||
{
|
||||
name: 'preventOverflow',
|
||||
fn: function () {
|
||||
return
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
const result = popperOptionsReenablePreventOverflow(config)
|
||||
|
||||
expect(result.modifiers.length).toBe(1)
|
||||
expect(result.modifiers[0].name).toBe('preventOverflow')
|
||||
expect(result.modifiers[0].options).toEqual({ padding: 10 })
|
||||
})
|
||||
})
|
24
src-ui/src/app/utils/popper-options.ts
Normal file
24
src-ui/src/app/utils/popper-options.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { Options } from '@popperjs/core'
|
||||
|
||||
export function popperOptionsReenablePreventOverflow(
|
||||
config: Partial<Options>
|
||||
): Partial<Options> {
|
||||
const preventOverflowModifier = config.modifiers?.find(
|
||||
(m) => m.name === 'preventOverflow' && m.fn?.length === 0
|
||||
)
|
||||
if (preventOverflowModifier) {
|
||||
config.modifiers.splice(
|
||||
config.modifiers.indexOf(preventOverflowModifier),
|
||||
1
|
||||
)
|
||||
}
|
||||
const ogPreventOverflowModifier = config.modifiers.find(
|
||||
(m) => m.name === 'preventOverflow'
|
||||
)
|
||||
if (ogPreventOverflowModifier) {
|
||||
ogPreventOverflowModifier.options = {
|
||||
padding: 10,
|
||||
}
|
||||
}
|
||||
return config
|
||||
}
|
Reference in New Issue
Block a user