-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feature/migrate slider component to flickity library #164
Feature/migrate slider component to flickity library #164
Conversation
Thank you, @AdrianFiroiu . As far as I can tell, this behavior seems to be by design and I don't see any issues keeping Currently it's not possible to pass this property down to |
Thank you, @AdrianFiroiu 👍 It appears that enabling I propose leaving this property off by default and leaving the decision to enable it to the component's consumer where the slider's reloading could be justified. |
I'm afraid that we will need it in the |
I'm afraid that the issue is even worse than originally anticipated. I've just been playing around with the current changes and have noticed that Flickity / Flickity React does not properly update options and does not rerender the slider upon option updates. More specifically, if an option like Another more elegant and simpler yet still a little hacky solution would be to recreate the entire component within React (for instance by changing |
3a33382
to
bd139f4
Compare
After looking further into the issue it seems to be significantly more complicated than anticipated. The issues lie with both the react component and the Flickity library itself. Starting with the react component - we can see withing Storybook that the this.flkty.options.draggable =
draggable === undefined
? children
? children.length > 1
: false
: draggable; Extending this to other options does fix them, such as: this.flkty.options.autoPlay = autoPlay === undefined ? false : autoPlay; But will not work for markup changes such as For the Flickity library itself the problem is known and discussed in these 2 PRs, PR381 & PR488, where the general gist is that initializing the slider has no issues but changes to the cells or props cause React to lose the reference to the children and throw an error we encounter as well: Implementing the changes proposed there did not initially fix the issue locally for me, although I will continue testing them. Could you please let me know your thoughts on the best way to move forward? Do you think it would make sense to start implementing our own react integration instead? CC @kuserich @mahdiyazdani |
Have you already started working on a wrapper component that we can use in the “Slider” block and have it initialized with support for reflecting changes as expected? I don’t think we can do much here, as the react library seems to be limiting us in terms of offering a live reflection of changes made to the slider settings in the editor. Reflecting instant changes associated with options such as page dots and navigation arrow icons would be essential to have in place for the slider component, as otherwise, we would need to add a temporary class name specific to the editor rendering of the block to toggle the visibility of these elements from the view in respect to the value assigned to each control. However, this might not work for settings like "arrow-shape," etc. |
This (currently) draft PR proposes the migration of the
slider
component and the associated stories to the Flickity library. For the reasons outlined below the changes are a WIP so I have made the minimum amount of changes necessary until this point.I have opted for importing the following React Flickity component and utilizing it instead of the Glider wrapper. However I have run into a blocking issue where some options are not enabled / disabled properly within the storybook.
For example, the
draggable
option toggle does not seem to work within the component when toggled even though in theoptions
prop it is set totrue
when toggled. A workaround for this particular case was using thereloadOnUpdate
prop of the new component (despite it being a costly operation).But, unfortunately, this solution does work for any other option toggle and I think we should discard it entirely. If we also reload the storybook page with the toggle arguments passed then the options work as expected.
Could you please also have a look at the changes in case I have missed anything regarding a solution? Thank you 🙂