react table lose input focus on change. V 6.10 - 6.8.6
Describe the bug Live https://codesandbox.io/s/6l7op9lovr After input value change, input is losing focus and we cannot type in more than 1 letter. When downgrade to 6.8.6 input is not losing focus after typing in 1 letter
To Reproduce Steps to reproduce the behavior:
- Go to https://codesandbox.io/s/6l7op9lovr website
- Click first input
- try to write more than 1 letter in input
- check that input has lost focus
- downgrade to 6.8.6
- Click first input
- try to write more than 1 letter
- notice that it s possible now
I have the same problem.
We are having same issue, Cell components seem to be unmounting and mounting whenever input value changes, which causes lost focus. With previous ver., this did not happened. https://codesandbox.io/s/reacttable-simple-table-6t7er?fontsize=14
Same here. Took a while to figure this out but luckily downgrade fixed it. I wonder how much will this change in v7
@PeterKottas, v7 is going to be headless, so anything pertaining to markup, or actually rendering components will be in your hands. Please check out the alpha sandbox in the readme to get a feel for what will be possible.
This is a major bug @tannerlinsley. It makes the tables totally unusable (double click is also failing for me because of lost focus).
I think just saying upgrade to v7 is not enough! Let's figure out which commit caused this issue and fix it!
Indeed, it is a major bug.
I would love that! If you can find the bug and fix it, I will merge a PR for it.
@tannerlinsley I'll take a peak, I do think you should probably revert/publish over v6.10 in the mean time
This could mean removing and breaking a lot of features that people have PR'd in since then. Which version were you thinking?
I'm doing some sleuthing on my end. Here is my best guess as to where the issue may have been introduced:

All the other changes between v6.8.6 and v.6.10 seem unlikely to have caused the issue to me.
You're maybe correct to hold off publishing over v6.10 if people are using the features they've added since. Let's try to find where this issue is arising
Yep. I would rather find the issue and patch it, rather than take a step backwards. It's bad either way: existing users are either having issues with this bug right now, or will have compatibility issues if we reset.
@tannerlinsley Ok, after playing with it a bit, it appears that the following change breaks double click for me:

I'm not sure if that change also causes the input focus loss that was the original issue filed here, but it definitely breaks double click for me.
@tannerlinsley what was that change meant to do?
Here I'm console logging "yar" on double click:
With v6.8 code:
function normalizeComponent (Comp, params = {}, fallback = Comp) {
return typeof Comp === 'function' ? (
Object.getPrototypeOf(Comp).isReactComponent ? (
<Comp {...params} />
) : (
Comp(params)
)
) : (
fallback
)
}

With v6.10 code:
function normalizeComponent (Comp, params = {}, fallback = Comp) {
return typeof Comp === 'function' ? <Comp {...params} /> : fallback
}

Hmm.. This was a long time ago in dev years, but I think React deprecated or discouraged using isReactComponent. We needed a quick way to tell if a component was a class, function, or JSX.
It's likely that if we simply improve that function to handle all of those edge cases we'll be okay.
Not that this is perfect, but here is what we are working with in v7:
export function flexRender(Comp, props) {
if (typeof Comp === 'function' || typeof Comp === 'object') {
return <Comp {...props} />
}
return Comp
}
Currently, it doesn't handle detecting JSX primitives, so you have to do this: Header: () => <span>Yo</span>, instead of just Header: <span>Yo</span>. I wish it did detect this though.
maybe we can follow the top voted answer here: https://stackoverflow.com/questions/33199959/how-to-detect-a-react-component-vs-a-react-element
?
Hmm... 🤔 https://twitter.com/dan_abramov/status/787739945301635073
It's really the difference between a react component and a react element.
A component is a class or function that has not been
I meant this one: https://stackoverflow.com/a/41658173/2178112
Yep. Those are perfect. We need to incorporate those into the render function for voth v6 and v7.
Would you like to test those out and update the older function? I'll work on the v7 impl.
Okay I put a PR in @tannerlinsley
Merged.