corbinrobb commented on a change in pull request #17386:
URL: https://github.com/apache/superset/pull/17386#discussion_r746192525



##########
File path: superset-frontend/src/SqlLab/components/TableElement/index.tsx
##########
@@ -77,6 +77,15 @@ const Fade = styled.div`
 const TableElement = ({ table, actions, ...props }: TableElementProps) => {
   const [sortColumns, setSortColumns] = useState(false);
   const [hovered, setHovered] = useState(false);
+  const [tableNameOverflow, setTableNameOverflow] = useState(false);
+  const tableNameRef = React.useRef<HTMLInputElement>(null);
+
+  useEffect(() => {
+    const element = tableNameRef.current;
+    if (element && element.offsetWidth < element.scrollWidth) {

Review comment:
       You caught me, I totally forgot about optional chaining again. I did go 
in here and try to change this to something like element?.offsetWidth < 
element?.scrollWidth and apparently typescript doesn't like that. It gives the 
error element can possibly be undefined and after a quick google, I eventually 
found my way to TypeScripts docs where it explains why. 
   
   So my intention is to not run the less than comparison unless the element 
exists but TS's issue is that optional chaining doesn't stop comparisons from 
happening the way that && does. They just return undefined if the object is 
null and TS doesn't like when you check if undefined is less than undefined, so 
it throws the error. Here is the release notes where they talk about it 
[typescript 
docs](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#nullish-coalescing)
   
   I don't know maybe I am just not looking hard enough. Any ideas on how to 
get around this that don't defeat the purpose?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to