Keyboard control

It's a Swiper module currently not included, yet it's quite common UX, expected for swiping/sliding. https://swiperjs.com/swiper-api#keyboard-control

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

nk_ created an issue. See original summary.

bbu23’s picture

Status: Active » Needs review
bbu23’s picture

Version: 2.0.x-dev » 2.1.x-dev
sebastix’s picture

Issue:

Warning: Undefined array key "keyboard" in /var/www/web/modules/contrib/swiper_formatter/src/Form/SwiperFormatterForm.php on line 549
Warning: Trying to access array offset on null in /var/www/web/modules/contrib/swiper_formatter/src/Form/SwiperFormatterForm.php on line 549
Warning: Undefined array key "keyboard" in /var/www/web/modules/contrib/swiper_formatter/src/Form/SwiperFormatterForm.php on line 556
Warning: Trying to access array offset on null in /var/www/web/modules/contrib/swiper_formatter/src/Form/SwiperFormatterForm.php on line 556
Warning: Undefined array key "keyboard" in /var/www/web/modules/contrib/swiper_formatter/src/Form/SwiperFormatterForm.php on line 568
Warning: Trying to access array offset on null in /var/www/web/modules/contrib/swiper_formatter/src/Form/SwiperFormatterForm.php on line 568

The swiper_formatter module is at version 2.0.x-dev and the patch https://git.drupalcode.org/project/swiper_formatter/-/merge_requests/24.... is applied correctly.
Also ran database updates but still, I got these PHP warnings. It seems `swiper_formatter_update_10206` is not getting executed when running database updates.

No default values (swiper options) are set for the key 'keyboard' in $default_array for existing updates or adding a new template.

bbu23’s picture

Hi @sebastix,

Just tested locally on Drupal 11 and Drupal 10.3. Grabbed the dev version, applied the patch, executed the updates. Everything worked as expected.

It's probably something on your end, unless you can provide more information.

On the other hand and non-related this made me think that we should've probably went for post_update instead. I'll decide on that later.

sebastix’s picture

Thx for the quick reply.

Did you test it on a clean install or existing installation?

I tried to fix the issue / debug why the `swiper_formatter_update_10206` function is not being called when I execute `drush updb` but no luck finding why yet. I'm working on a existing installation where 2.0.1 was installed before I switched to 2.0.x-dev with the patch.

bbu23’s picture

I have a few dummy projects that I use for testing contributed scenarios. They're not really clean anymore, but not existing if that makes sense.

What I can tell you for sure is that I followed these steps:
1. swiper_formatter was uninstalled or I uninstalled myself
2. downloaded the latest dev version using composer
3. installed the swiper_formatter module
4. applied the patch from the MR
5. navigated to the default swiper formatter entity and observed the warnings (which is as expected)
6. ran drush updb to apply the update (successfully)
7. refreshed the swiper entity page to observe that the warnings are run

If swiper_formatter was already enabled with version 2.0.1 before applying the patch, then I don't explain how the update could've been skipped unless you've already had an update with that same number somehow or if the module was disabled and got enabled after applying the patch, which doesn't seem the case.

Either way, I suggest verifying that the last update schema number is actually 10206 using drush ev "echo \Drupal::service('update.update_hook_registry')->getInstalledVersion('swiper_formatter');". You could modify it manually to have the update run again, or maybe you can grab a database of your project and redo the test.

sebastix’s picture

drush ev "echo \Drupal::service('update.update_hook_registry')->getInstalledVersion('swiper_formatter');" returned 10206 so that seem to be fine.

I've set the version back to 10205 with drush ev "\Drupal::service('update.update_hook_registry')->setInstalledVersion('swiper_formatter', 10205);" and ran drush updb again and now the update shows up to be executed.

So now with this working, the update is run properly and the existing templates are getting updated which solves the issue with the PHP warnings about missing default values when editing a template.

With that said, the new keyboard feature is working on the frontend when viewing images.

bbu23’s picture

Perfect, thank you for confirming @sebastix.
Yes, it seems like your update was marked as executed for some reason.

bbu23’s picture

Status: Needs review » Needs work

We might need to update the default config to contain the keyboard addition.

bbu23’s picture

Assigned: nk_ » bbu23

  • bbu23 committed 9ee50c5e on 2.1.x
    test: #3537404 Add update path test for keyboard control post_update
    

  • bbu23 committed ca4c2a34 on 2.1.x authored by nk_
    feat: #3537404 Add Keyboard control module
    

  • bbu23 committed 1524acf3 on 2.1.x
    refactor: #3537404 Add isBreakpoint method to Swiper entity
    
bbu23’s picture

Assigned: bbu23 » Unassigned
Status: Needs work » Fixed

Thanks guys, this will be available in 2.1.0

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.