[Discover] Discover Classic View Filter In/Out placement when truncate:maxHeight is set to 0 (#129942)

* Change global injected CSS for truncating height
* Optimize CSS code
* Add requiresPageReload for TRUNCATE_MAX_HEIGHT
This commit is contained in:
Matthias Wilhelm 2022-04-14 14:15:48 +02:00 committed by GitHub
parent 4835a5d7d1
commit 1f05cd606d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 12 deletions

View file

@ -124,3 +124,7 @@
}
}
}
.dscTruncateByHeight {
display: inline-block;
}

View file

@ -18,12 +18,19 @@ const TRUNCATE_GRADIENT_HEIGHT = 15;
const globalThemeCache = createCache({ key: 'truncation' });
const buildStylesheet = (maxHeight: number) => {
if (!maxHeight) {
return [
`
.dscTruncateByHeight {
max-height: none;
}`,
];
}
return [
`
.dscTruncateByHeight {
overflow: hidden;
max-height: ${maxHeight}px !important;
display: inline-block;
}
.dscTruncateByHeight:before {
top: ${maxHeight - TRUNCATE_GRADIENT_HEIGHT}px;
@ -32,18 +39,7 @@ const buildStylesheet = (maxHeight: number) => {
];
};
const flushThemedGlobals = () => {
globalThemeCache.sheet.flush();
globalThemeCache.inserted = {};
globalThemeCache.registered = {};
};
export const injectTruncateStyles = (maxHeight: number) => {
if (maxHeight <= 0) {
flushThemedGlobals();
return;
}
const serialized = serializeStyles(buildStylesheet(maxHeight), cache.registered);
if (!globalThemeCache.inserted[serialized.name]) {
globalThemeCache.insert('', serialized, globalThemeCache.sheet, true);

View file

@ -286,5 +286,6 @@ export const getUiSettings: (docLinks: DocLinksServiceSetup) => Record<string, U
'The maximum height that a cell in a table should occupy. Set to 0 to disable truncation.',
}),
schema: schema.number({ min: 0 }),
requiresPageReload: true,
},
});