Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need help with focus on the dynamic particular element. #10

Open
pahonski opened this issue Mar 19, 2019 · 45 comments
Open

Need help with focus on the dynamic particular element. #10

pahonski opened this issue Mar 19, 2019 · 45 comments

Comments

@pahonski
Copy link

Снимок экрана 2019-03-19 в 10 03 05
How can i put focus on the fourth element in the second vertical list programmatically.

@dead
Copy link
Owner

dead commented Mar 19, 2019

If you pass forceFocus={true} props to the fourth Focusable element it will be focused when the component mount.

@pahonski
Copy link
Author

Thank you! But i create the sidebar component when my main component render. I do this because key-navigation doesn't work correct with many dynamic elements. I forced create all my focusable components when my main component render and set for them for example 'display: none'. My component mount 1 time and never unmounted while i am on the main component.

@dead
Copy link
Owner

dead commented Mar 20, 2019

Just fixed #3.
Maybe that will help you.

@pahonski
Copy link
Author

pahonski commented Mar 21, 2019

When i used forseFocus props, it works.
Снимок экрана 2019-03-21 в 18 00 22
But when i clicked UP, focus went on the first element, not on the third.

@pahonski
Copy link
Author

pahonski commented Mar 21, 2019

Sorry, i don't understand how it works.

<VerticalList>
{this.state.dynamicInsert && <Search text="inserted!!" />}
</VerticalList>

In example which i found in the issue#3 it doesn't work.

@dead
Copy link
Owner

dead commented Mar 21, 2019

Did you update to 0.0.10? The same example in #3 with version 0.0.10 https://codesandbox.io/s/50xy2z3244

<VerticalList>
{this.state.dynamicInsert && <Search text="inserted!!" />}
</VerticalList>

The code above works in version 0.0.9 because the "VerticalList" is already monted, so when the dynamic component is inserted it will be in the correct order/position (the first element of that VerticalList). Same example in #3 using the code above

In version 0.0.10 you don't need VerticalList because it will re-order the children components when the parent component is updated. So just using {this.state.dynamicInsert && <Search text="inserted!!" />} should be fine.

@pahonski
Copy link
Author

pahonski commented Mar 21, 2019

But i need one horizontal list which include 2 vertical lists. The first list for seasons and the second for the series. When i remove Vertical list it doesn't work correct.
Снимок экрана 2019-03-21 в 20 25 55

And i get new error with version 0.0.10 when i re-render component withe series.
Снимок экрана 2019-03-21 в 20 19 15
Could you tell me what will i need change in my code. I tried to do as you wrote, but it doesn't help me.
May be i can't use array with dynamic elements?

@pahonski pahonski reopened this Mar 21, 2019
@pahonski
Copy link
Author

https://youtu.be/bSeYduApEc4
I attached video with problem.

@dead
Copy link
Owner

dead commented Mar 21, 2019

I think I found out what was your problem, I'm going to fix it soon.

@pahonski
Copy link
Author

pahonski commented Mar 22, 2019

I'm looking forward to fix this problem.

@dead
Copy link
Owner

dead commented Mar 22, 2019

Please try the v0.0.11

@pahonski
Copy link
Author

Hello, i have new problem with focusable elements after update. I try to explain it soon. But old problem with correct KEY UP and KEY DOWN isn't fixed.

@pahonski
Copy link
Author

https://youtu.be/mCmKylez4s4

Now i can't switch to window with PLAY button when i press KEY_UP.
Снимок экрана 2019-03-24 в 10 25 53

This element doesn't dynamic. It has diplay:none. When data are received element is changed display to flex.
In the version 0.0.10 it works good, but now it doesn't work.

Main component with navigation:
Снимок экрана 2019-03-24 в 10 33 22

Menu component
Снимок экрана 2019-03-24 в 10 34 32

ContentList component (films posters).
Снимок экрана 2019-03-24 в 10 36 04

I don't know if i explained well. I will record video if you don't understand my problem.

@pahonski
Copy link
Author

https://youtu.be/t7VmV8o5dCo

In this video i compare version 9 and 11

@pahonski
Copy link
Author

pahonski commented Mar 25, 2019

I noticed that the focus is lost when the component is updated. In my case it happened when i get new data from redux. It starts to work incorrectly.

@dead
Copy link
Owner

dead commented Mar 25, 2019

Thanks for the feedback! But I couldn't reproduce your error...
Can you change to mount the component only when it should be visible?
That is the only thing that could bug the navigation system because even though it is not visible the navigation is not aware of that. If that is your problem I can create a props disabled that would make the navigation ignore it.

@pahonski
Copy link
Author

Thank you, this props will be good. On this week i'll try to find, where i get this problem. I'll write about it soon.

@pahonski
Copy link
Author

pahonski commented Mar 26, 2019

Now i describe other problems, which i noticed.

  1. When my project was downloaded i see some react-dom errors in the console. Without last warning.
    1
    2
  2. I have search keyboard with focusable buttons, but it doesn't that behaviour which i wanted.
    https://youtu.be/VAT4_FTInoE

When I focus keyboard and press KEYDOWN i want to go on the second row not ont the menu below.
This is the keyboard code:
01

This is the Menu code which include keyboard
02

@pahonski
Copy link
Author

pahonski commented Mar 26, 2019

  1. Bug with dynamic element when it appears.
    https://youtu.be/ibXfLau5IL4
    this element
    6

@pahonski
Copy link
Author

pahonski commented Mar 26, 2019

I tried dynamical elements in more simple component, but it doesn't work too.

I have Tv component with navigation and other components.
1
Sidebar same as in your example in youtube-tv.
666
List with tv channels which i get from ajax
3
And list items
4

Focus works only on sidebar static element, when i get tv channels list from ajax, they don't get focus.
video
https://youtu.be/l4VPEaWwYGg

@pahonski
Copy link
Author

pahonski commented Mar 26, 2019

I added code on the codesandbox.

https://codesandbox.io/s/xlnvr9zr9w

@dead
Copy link
Owner

dead commented Mar 26, 2019

Update to v.0.0.12 https://codesandbox.io/s/622xk79vvw and now this example work 😄

@pahonski
Copy link
Author

pahonski commented Mar 27, 2019

Hello i noticed another problem.
When i render Focusable items as in this example this code works good.
1

But when i render Focusable element in the component as in this example it works one time. Sidebar open and close. But then i don't focus this sidebar.
3

This is component which include focusable.
2

@dead
Copy link
Owner

dead commented Mar 27, 2019

Can you reproduce this in codesandbox? I tried https://codesandbox.io/s/ryrnxz902n but it works

@pahonski
Copy link
Author

Maybe this video can help.
https://youtu.be/nHktSpwZ168

@pahonski
Copy link
Author

I found this bug.
https://codesandbox.io/s/72o5yj4mn1

@dead
Copy link
Owner

dead commented Mar 27, 2019

Can you try the new version (v0.0.13)?

@pahonski
Copy link
Author

pahonski commented Mar 27, 2019

Yes, it's working. Thank you. Did you add props "disabled"? And how can i set navDeafult on the vertical list which include dynamic elements?

@dead
Copy link
Owner

dead commented Mar 27, 2019

Still haven't added the disabled props. The navDeafult sets the element the navigation will focus when it will lose a focus or the when the navigation start (after loading the page). You want something that when you enter a VerticalList it will focus a specific element?

@pahonski
Copy link
Author

It would be nice:

  1. when I enter a VerticalList it will focus a specific element.
  2. when i have opportunity to set navDefault on the VerticalList which doesn't has children elements, but it is going to get them from ajax.

@pahonski
Copy link
Author

And props "disabled" :)

@pahonski
Copy link
Author

pahonski commented Apr 1, 2019

Hello, are you going to make changes soon?

@pahonski
Copy link
Author

pahonski commented Apr 1, 2019

How can i clean this list http://joxi.ru/brRgav6i7Qaeam.
When i create a lot of dynamic elements this list gets bigger and bigger.

@dead
Copy link
Owner

dead commented Apr 1, 2019

Hey, I kind busy this week, so I'm not sure if i will able to do something.

Does this list cause you performance issues?
I only use that to keep a reference of the focusable components.

@pahonski
Copy link
Author

pahonski commented Apr 1, 2019

What about this? It is very important.
http://joxi.ru/VrwyVZlI7OKjO2

About performance. Now i don't have problems but in future it might be.

@pahonski
Copy link
Author

pahonski commented Apr 4, 2019

Hello, i have a new problem with forceFocus.
In this app i show a simple example.
https://codesandbox.io/s/72o5yj4mn1

I tried forceFocus from left sidebar. I have to focus right items when I press SPACE button. It works, but then when i return on the left sidebar after this manipulations, KEY_UP and KEY_DOWN doesn't work.

When i have to change SPACE (which i described above) on KEY_LEFT? Can I use event.stopPropagation and forceFocus?

@pahonski
Copy link
Author

pahonski commented Apr 6, 2019

Could you fix at least this bug please?

@dead
Copy link
Owner

dead commented Apr 6, 2019

I going to try fixing this issue tomorrow.

@pahonski
Copy link
Author

pahonski commented Apr 7, 2019

Thank you. I will looking forward to.

@dead
Copy link
Owner

dead commented Apr 7, 2019

Sorry, I'm not going to be able to fix that today. I'm without internet at home. Hope I can fix it Monday.

@pahonski
Copy link
Author

pahonski commented Apr 7, 2019

Sure. I hope it too.

@pahonski
Copy link
Author

pahonski commented Apr 9, 2019

Unfortunately forceFocuses don't work anywhere :( I noticed that things which worked before, don't work now.

@dead
Copy link
Owner

dead commented Apr 9, 2019

Yeah, I tried to fix the issue yesterday, but no success. The problem all comes down to the issue #3. The "solution" I found is wrong and doesn't work properly at all.
Probably I will need to rewrite most part of the library to work around this (and not even sure if this is possible).

I recommend you to try https://github.com/dead/react-js-spatial-navigation or even the pure js library https://github.com/luke-chang/js-spatial-navigation

@pahonski
Copy link
Author

pahonski commented Apr 9, 2019

We wrote much code with your library. Could you finish some important things for a fee?

@pahonski
Copy link
Author

pahonski commented Apr 16, 2019

Thank you for a help. I'll try your library https://github.com/dead/react-js-spatial-navigation. But i don't see in it forceFocus :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants