corbinrobb commented on a change in pull request #17386:
URL: https://github.com/apache/superset/pull/17386#discussion_r746177402
##########
File path: superset-frontend/src/SqlLab/components/TableElement/index.tsx
##########
@@ -221,12 +230,15 @@ const TableElement = ({ table, actions, ...props }:
TableElementProps) => {
>
<Tooltip
id="copy-to-clipboard-tooltip"
- placement="topLeft"
style={{ cursor: 'pointer' }}
title={table.name}
- trigger={['hover']}
+ trigger={tableNameOverflow ? ['hover'] : []}
Review comment:
Hello! I had to double check my knowledge on refs for a moment and also
try this out because it would be awesome if I did not have to use the useEffect
but unfortunately, it isn't working for me.
If I understand React and refs correctly the ref only becomes defined after
the element that it is attached to renders. So if I were to check if the width
is longer than the container and put it in a const React would just say null <
null and the ternary would go to the false value before the component even
fully renders. Since there is nothing causing a change of state on that
component, React won't rerender it again.
The useEffect will wait until the component renders and then run once. We
need this because the ref won't exist or have a length until it is rendered.
Then we update the state of the conditional and then react will rerender any
element using the state and the conditional will remove the hover trigger.
My apologies if I am not explaining this well enough or if I completely
misunderstood what you are suggesting
--
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]