mirror of
https://github.com/fleetdm/fleet
synced 2026-05-15 13:08:42 +00:00
For #27283 This includes the work to add the new users card on host details and show the new idp information as well as google profiles and other emails. This includes: **new user card on the host details and my device page**  **rework of the grid layout on the host page** **removal of unneeded device mapping code on host details and my device page** I've changed how we are using the grid layout in CSS to better support dynamic rendering content <!-- Note that API documentation changes are now addressed by the product design team. --> - [x] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. - [ ] Added/updated automated tests - [ ] Manual QA for all new/changed functionality
26 lines
779 B
TypeScript
26 lines
779 B
TypeScript
import { useLayoutEffect, useState } from "react";
|
|
|
|
/**
|
|
* This hook checks if an element is truncated and returns a boolean value.
|
|
*/
|
|
// eslint-disable-next-line import/prefer-default-export
|
|
export const useCheckTruncatedElement = <T extends HTMLElement>(
|
|
ref: React.RefObject<T>
|
|
) => {
|
|
const [isTruncated, setIsTruncated] = useState(false);
|
|
|
|
useLayoutEffect(() => {
|
|
const element = ref.current;
|
|
function updateIsTruncated() {
|
|
if (element) {
|
|
const { scrollWidth, clientWidth } = element;
|
|
setIsTruncated(scrollWidth > clientWidth);
|
|
}
|
|
}
|
|
window.addEventListener("resize", updateIsTruncated);
|
|
updateIsTruncated();
|
|
return () => window.removeEventListener("resize", updateIsTruncated);
|
|
}, [ref]);
|
|
|
|
return isTruncated;
|
|
};
|