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

Component: confirmation menu #2723

Open
wants to merge 51 commits into
base: dev
Choose a base branch
from

Conversation

crhallberg
Copy link
Contributor

@crhallberg crhallberg commented Feb 23, 2023

Are you sure you want to do this?

  • Basic HTML with translations
  • Minimal JS
    • Menu JS
  • Tests
    • Fix keyboard control tests
  • Use with Corrects non-validating cart dropdown menus #2669.
  • Integrate into existing confirmation templates:
    • cart/cart.phtml
    • holds/list.phtml
    • librarycards/home.phtml
    • myresearch/checkedout.phtml
    • myresearch/illrequests.phtml
    • myresearch/mylist.phtml
    • myresearch/storageretrievalrequests.phtml
    • RecordDriver/DefaultRecord/list-entry.phtml
  • Make sure all Mink tests still pass

@crhallberg crhallberg marked this pull request as draft February 23, 2023 20:12
@demiankatz
Copy link
Member

Thanks for getting this started, @crhallberg -- please let me know when you're ready for a review! Looks like there are some automated check things that need to get sorted out, so for now I'll let you work on those before I add to the to-do list. ;-)

@crhallberg
Copy link
Contributor Author

crhallberg commented Mar 8, 2023

I'm hesitant about reimplementing the ARIA components from scratch but up until today I hadn't found a good non-React library. Today I found goodguyry's AriaComponents repository.

I think these are a good step up from the Javascript W3C provides and they seem thoroughly tested and maintained. The only warning that I have is that the demo page is using the latest release, which is a year old. I manually tested the dev branch (updated very recently) and it so far fixes all of my issues with the demo (such as down-arrow events on the Tabs interface).

I think this would be a good thing to adopt immediately, seeing as it doesn't require a build step, only modern JS importing.

cc. @demiankatz @EreMaijala (please cc others)

@crhallberg
Copy link
Contributor Author

I've dug even deeper now and the results aren't as promising as expected. It seems that they deprecated MenuButton and MenuBar and say vaguely that it's best to "build your own using the Disclosure or Dialog component", but there aren't any examples of this and no instruction for MenuBar.

@demiankatz
Copy link
Member

@crhallberg, thanks for the research here! As we discussed last week, I'd be inclined to split this work into two parts:

Part 1: refactor the existing yes/no drop-down functionality to a component template, so we can standardize and centralize the current behavior.

Part 2: rewrite the refactored component template to use more modern behavior.

Since the "part 2" seems like it still requires research, I'd favor getting part 1 done for release 9.0 and then finishing part 2 later as time permits. (And of course, maybe there's a "part 1.5" where we improve the accessibility of the existing behavior without a full rewrite of everything).

@crhallberg crhallberg marked this pull request as ready for review March 10, 2023 17:56
@demiankatz
Copy link
Member

demiankatz commented Mar 10, 2023

EDIT: never mind -- the test failure I was seeing seems unrelated to this branch; investigating now, but I'll test this more thoroughly next week once whatever else is wrong gets resolved.

EDIT 2: I restarted my test environment and everything is passing now. Just a passing glitch, apparently.

Copy link
Member

@demiankatz demiankatz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again, @crhallberg. I've given this a closer look and found a few things to discuss. I haven't tried any hands-on testing yet, but I'll do that once we get through the more theoretical parts of the conversation. :-)

Copy link
Member

@demiankatz demiankatz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the progress here, @crhallberg -- I think that all but one of my prior review comments are now addressed... so next steps are:

1.) Resolve conflicts (looks like just a "merge and recompile CSS" situation)
2.) Begin refactoring existing confirm menus to use this component
3.) Make sure tests pass

Let me know how I can help!

@demiankatz demiankatz added this to the 9.0 milestone Mar 17, 2023
@demiankatz
Copy link
Member

demiankatz commented Mar 22, 2023

@crhallberg, I took a moment this morning to merge the latest dev into this branch to make sure styles are all good after recent changes (fortunately, they are).

I also tried to start using the component to replace existing confirm menus, but I think several key features are currently missing. The first instance of a confirm menu that I could find is in the cart (cart/cart.phtml, which is also the subject of #2669 which started this whole process) for the delete buttons. I started by adding:

        <?=
          $this->component(
            'confirm-menu',
            [
              'label' => $this->transEsc('Delete'),
              'toggleClassAttr' => 'toolbar-btn dropdown-toggle',
            ]
          )
        ?>

Above the existing delete code. The button doesn't open a menu (maybe it doesn't work inside a lightbox, or I missed some important attribute?) and it also lacks capabilities for including an icon inside the button, attaching an ID to the button, or attaching IDs to the contents of the drop-down menu. I assume that some or all of these things are required in order to refactor functionality like the cart to use this component. (But I apologize if I'm missing/misunderstanding something).

@demiankatz
Copy link
Member

@crhallberg, I've merged the latest dev into this PR to bring things up to date. There's still a lot of work to be done here; we'll discuss on next week's Community Call.

@demiankatz demiankatz modified the milestones: 9.1, 10.0 Aug 1, 2023
EreMaijala pushed a commit to EreMaijala/vufind that referenced this pull request Oct 13, 2023
@demiankatz demiankatz added architecture pull requests that involve significant refactoring / architectural changes and removed new feature labels Nov 7, 2023
@demiankatz
Copy link
Member

I've done another round of merging and conflict resolution to bring this up to date, but several things seem to be broken at the moment. Here's the current test output:

There was 1 error:

1) VuFindTest\Integration\View\Helper\Root\ComponentTest::testConfirmMenu
Undefined array key "class"

/usr/local/vufind/themes/bootstrap3/templates/_ui/components/confirm-menu.phtml:7
/usr/local/vufind/vendor/laminas/laminas-view/src/Renderer/PhpRenderer.php:526
/usr/local/vufind/module/VuFind/src/VuFind/View/Helper/Root/Component.php:65
/usr/local/vufind/module/VuFind/tests/integration-tests/src/VuFindTest/View/Helper/Root/ComponentTest.php:113
/usr/local/vufind/module/VuFind/tests/integration-tests/src/VuFindTest/View/Helper/Root/ComponentTest.php:135
/usr/local/vufind/module/VuFind/src/VuFindTest/Feature/AutoRetryTrait.php:104

--

There were 6 failures:

1) VuFindTest\Mink\HoldsTest::testCancelHold
Element not found: .alert.alert-success index 0
Failed asserting that null is of type "object".

/usr/local/vufind/module/VuFind/src/VuFindTest/Integration/MinkTestCase.php:407
/usr/local/vufind/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/HoldsTest.php:386
/usr/local/vufind/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/HoldsTest.php:422
/usr/local/vufind/module/VuFind/src/VuFindTest/Feature/AutoRetryTrait.php:104

2) VuFindTest\Mink\HoldsTest::testFrozenHoldEditingWithCancellation
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'1 request(s) were successfully canceled'
+'1 hold(s) updated'

/usr/local/vufind/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/HoldsTest.php:644
/usr/local/vufind/module/VuFind/src/VuFindTest/Feature/AutoRetryTrait.php:104

3) VuFindTest\Mink\IlsActionsTest::testCancelAllIllRequest
Element not found: .alert.alert-success index 0
Failed asserting that null is of type "object".

/usr/local/vufind/module/VuFind/src/VuFindTest/Integration/MinkTestCase.php:407
/usr/local/vufind/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/IlsActionsTest.php:251
/usr/local/vufind/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/IlsActionsTest.php:452
/usr/local/vufind/module/VuFind/src/VuFindTest/Feature/AutoRetryTrait.php:104

4) VuFindTest\Mink\IlsActionsTest::testCancelSelectedIllRequest
Element not found: .alert.alert-success index 0
Failed asserting that null is of type "object".

/usr/local/vufind/module/VuFind/src/VuFindTest/Integration/MinkTestCase.php:407
/usr/local/vufind/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/IlsActionsTest.php:214
/usr/local/vufind/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/IlsActionsTest.php:465
/usr/local/vufind/module/VuFind/src/VuFindTest/Feature/AutoRetryTrait.php:104

5) VuFindTest\Mink\IlsActionsTest::testCancelAllStorageRetrievalRequest
Element not found: .alert.alert-success index 0
Failed asserting that null is of type "object".

/usr/local/vufind/module/VuFind/src/VuFindTest/Integration/MinkTestCase.php:407
/usr/local/vufind/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/IlsActionsTest.php:251
/usr/local/vufind/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/IlsActionsTest.php:526
/usr/local/vufind/module/VuFind/src/VuFindTest/Feature/AutoRetryTrait.php:104

6) VuFindTest\Mink\IlsActionsTest::testCancelSelectedStorageRetrievalRequest
Element not found: .alert.alert-success index 0
Failed asserting that null is of type "object".

/usr/local/vufind/module/VuFind/src/VuFindTest/Integration/MinkTestCase.php:407
/usr/local/vufind/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/IlsActionsTest.php:214
/usr/local/vufind/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/IlsActionsTest.php:539
/usr/local/vufind/module/VuFind/src/VuFindTest/Feature/AutoRetryTrait.php:104

ERRORS!
Tests: 2568, Assertions: 14582, Errors: 1, Failures: 6.

Copy link
Member

@demiankatz demiankatz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm currently running through all open PRs to prevent outdated PHP version 7 comments from bleeding back into the project. See comment below -- just flagging this so we fix it before merging.

@demiankatz
Copy link
Member

Thanks for the latest progress, @crhallberg. I resolved conflicts again and ran the test suite. Here's the current state of test failures:

There were 5 errors:

1) VuFindTest\Mink\HoldsTest::testCancelHold
Exception: Failed to get text after 6 attempts.

/usr/local/vufind/module/VuFind/src/VuFindTest/Integration/MinkTestCase.php:691
/usr/local/vufind/module/VuFind/src/VuFindTest/Integration/MinkTestCase.php:610
/usr/local/vufind/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/HoldsTest.php:473
/usr/local/vufind/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/HoldsTest.php:509

2) VuFindTest\Mink\IlsActionsTest::testCancelAllIllRequest
Exception: Failed to get text after 6 attempts.

/usr/local/vufind/module/VuFind/src/VuFindTest/Integration/MinkTestCase.php:691
/usr/local/vufind/module/VuFind/src/VuFindTest/Integration/MinkTestCase.php:610
/usr/local/vufind/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/IlsActionsTest.php:254
/usr/local/vufind/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/IlsActionsTest.php:451

3) VuFindTest\Mink\IlsActionsTest::testCancelSelectedIllRequest
Exception: Failed to get text after 6 attempts.

/usr/local/vufind/module/VuFind/src/VuFindTest/Integration/MinkTestCase.php:691
/usr/local/vufind/module/VuFind/src/VuFindTest/Integration/MinkTestCase.php:610
/usr/local/vufind/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/IlsActionsTest.php:217
/usr/local/vufind/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/IlsActionsTest.php:464

4) VuFindTest\Mink\IlsActionsTest::testCancelAllStorageRetrievalRequest
Exception: Failed to get text after 6 attempts.

/usr/local/vufind/module/VuFind/src/VuFindTest/Integration/MinkTestCase.php:691
/usr/local/vufind/module/VuFind/src/VuFindTest/Integration/MinkTestCase.php:610
/usr/local/vufind/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/IlsActionsTest.php:254
/usr/local/vufind/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/IlsActionsTest.php:525

5) VuFindTest\Mink\IlsActionsTest::testCancelSelectedStorageRetrievalRequest
Exception: Failed to get text after 6 attempts.

/usr/local/vufind/module/VuFind/src/VuFindTest/Integration/MinkTestCase.php:691
/usr/local/vufind/module/VuFind/src/VuFindTest/Integration/MinkTestCase.php:610
/usr/local/vufind/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/IlsActionsTest.php:217
/usr/local/vufind/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/IlsActionsTest.php:538

--

There were 2 failures:

1) VuFindTest\Mink\HoldsTest::testFrozenHoldEditingWithCancellation
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'1 request(s) were successfully canceled'
+'1 hold(s) updated'

/usr/local/vufind/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/HoldsTest.php:731

2) VuFindTest\Integration\View\Helper\Root\ComponentTest::testConfirmMenu
Failed asserting that false is true.

/usr/local/vufind/module/VuFind/tests/integration-tests/src/VuFindTest/View/Helper/Root/ComponentTest.php:141
/usr/local/vufind/module/VuFind/tests/integration-tests/src/VuFindTest/View/Helper/Root/ComponentTest.php:170

ERRORS!
Tests: 2733, Assertions: 17580, Errors: 5, Failures: 2.

@demiankatz
Copy link
Member

Now that #3545 has been merged, there are some new conflicts to resolve here. Not sure if @crhallberg or @EreMaijala would be best positioned to do that, but either way, I'm happy to help if my help is needed... just let me know! I'll likely prioritize other tasks until somebody explicitly asks me to look at this one. :-)

@crhallberg
Copy link
Contributor Author

It appears to me that the confirm-menu component in this PR has been superseded by the confirm-button component from #3545. I wanted to make sure that was the case as I compare the differences and perhaps apply the tests to confirm-button.

@demiankatz
Copy link
Member

@crhallberg, I believe that is correct. I didn't notice that the component had a different name in #3545 than it did here; sorry for failing to catch that! I believe the intent was to refactor the code in #3545 while leaving the underlying mechanics intact, and then use this PR to revise the component to use more modern methods.

@demiankatz demiankatz modified the milestones: 10.0, 11.0 Jun 14, 2024
@demiankatz
Copy link
Member

I'm pushing all theme-related PRs that were not finished in time for 10.0 to the 11.0 milestone; it will be easier to finish these if we only have to operate on one theme at a time. I think we should establish a dev-11.0 branch fairly early in the 10.1 development process so that this work can move forward as soon as possible.

@demiankatz demiankatz changed the base branch from dev to dev-11.0 August 27, 2024 10:45
@demiankatz demiankatz changed the base branch from dev-11.0 to dev November 1, 2024 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accessibility architecture pull requests that involve significant refactoring / architectural changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants