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

Add interactivity to lesson steps #7538

Merged
merged 41 commits into from
Mar 19, 2024
Merged

Conversation

renatho
Copy link
Contributor

@renatho renatho commented Mar 13, 2024

Resolves #7478
Based off of #7535

Proposed Changes

  • Add interactivity to lesson tour.
  • It also adds a new feature to the code, allowing to add a beforeEach to run before each action.

Testing Instructions

  1. Make sure your local env is set to development (to enable the feature flag)
  2. Create a new lesson or open an existing one in the editor (You'll need a new user in case you've closed the tour before, or you can remove the value of the usermeta sensei_tours)
  3. Now go through each of the tour steps
  4. Go both forward and backwards in the tour
  5. Make sure the interactivity works as expected
  6. Check that Add interactivity to course steps #7535 continues working properly

Video

Screen.Recording.2024-03-14.at.15.41.55-2.mov

Pre-Merge Checklist

  • PR title and description contain sufficient detail and accurately describe the changes
  • Acceptance criteria is met
  • Decisions are publicly documented
  • Adheres to coding standards (PHP, JavaScript, CSS, HTML)
  • All strings are translatable (without concatenation, handles plurals)
  • Follows our naming conventions (P6rkRX-4oA-p2)
  • Hooks (p6rkRX-1uS-p2) and functions are documented
  • New UIs are responsive and use a mobile-first approach
  • New UIs match the designs
  • Different user privileges (admin, teacher, subscriber) are tested as appropriate
  • Legacy courses (course without blocks) are tested
  • Code is tested on the minimum supported PHP and WordPress versions
  • User interface changes have been tested on the latest versions of Chrome, Firefox and Safari
  • "Needs Documentation" label is added if this change requires updates to documentation
  • Known issues are created as new GitHub issues

@renatho renatho self-assigned this Mar 13, 2024
@renatho renatho changed the base branch from trunk to add/interaction-on-course-step March 13, 2024 18:02
@renatho renatho changed the title Add/interaction on lesson step Add interactivity to lesson steps Mar 13, 2024
Copy link

github-actions bot commented Mar 13, 2024

WordPress Dependencies Report

The github-action-wordpress-dependencies-report action has detected some script changes between the commit da17671 and trunk. Please review and confirm the following are correct before merging.

Script Handle Added Dependencies Removed Dependencies Total Size Size Diff
blocks/quiz/index.js 31.2 kB +6 B ( +0.02% 🔼 )
admin/tour/course-tour/index.js wp-block-editor, wp-editor 36.3 kB +285 B ( +0.8% 🔼 )
admin/tour/lesson-tour/index.js wp-block-editor, wp-edit-post, wp-editor 36.5 kB +2.3 kB ( +6.73% 🔼 )

This comment was automatically generated by the github-action-wordpress-dependencies-report action.

Copy link

codecov bot commented Mar 13, 2024

Codecov Report

Attention: Patch coverage is 38.15789% with 94 lines in your changes are missing coverage. Please review.

Project coverage is 51.78%. Comparing base (05d19fa) to head (da17671).
Report is 52 commits behind head on trunk.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##              trunk    #7538      +/-   ##
============================================
- Coverage     51.92%   51.78%   -0.15%     
- Complexity    11265    11307      +42     
============================================
  Files           630      640      +10     
  Lines         47683    48115     +432     
  Branches        421      467      +46     
============================================
+ Hits          24759    24914     +155     
- Misses        22587    22822     +235     
- Partials        337      379      +42     
Files Coverage Δ
assets/admin/tour/lesson-tour/index.js 54.54% <ø> (ø)
assets/blocks/quiz/quiz-block/quiz-settings.js 68.42% <0.00%> (ø)
assets/admin/tour/course-tour/steps.js 1.85% <25.00%> (-98.15%) ⬇️
assets/admin/tour/helper.js 80.00% <83.33%> (ø)
...ets/admin/tour/components/sensei-tour-kit/index.js 60.71% <50.00%> (-12.62%) ⬇️
assets/admin/tour/lesson-tour/steps.js 32.23% <31.66%> (-67.77%) ⬇️

... and 15 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d10be87...da17671. Read the comment docs.

/**
* Performs step actions one after another.
*
* @param {Array} stepActions An array of selectors to highlight.
*/
export async function performStepActionsAsync( stepActions ) {
removeHighlightClasses();
clearTimeout( stepActionTimeout );
Copy link
Contributor Author

@renatho renatho Mar 13, 2024

Choose a reason for hiding this comment

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

This is to make sure actions won't happen later after moving to different steps because of the setTimeout. Based on the removeHighlightClasses(); call in the previous line, I suppose we can assume that the performStepActionsAsync is a requirement in the actions, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes I think so in general. Thanks for the improvement! Just added a comment about it here #7538 (comment)

@Automattic Automattic deleted a comment from github-actions bot Mar 13, 2024
@Automattic Automattic deleted a comment from github-actions bot Mar 13, 2024
@Automattic Automattic deleted a comment from github-actions bot Mar 13, 2024
@Automattic Automattic deleted a comment from github-actions bot Mar 13, 2024
@Automattic Automattic deleted a comment from github-actions bot Mar 13, 2024
@Automattic Automattic deleted a comment from github-actions bot Mar 13, 2024
Copy link

Test the previous changes of this PR with WordPress Playground.

@@ -24,9 +24,16 @@ import { WpcomTourKit } from '@automattic/tour-kit';
* @param {string} props.tourName The unique name of the tour.
* @param {string} props.trackId ID of tracking event (optional). Tracking will be enabled only when provided.
* @param {TourStep[]} props.steps An array of steps to include in the tour.
* @param {Function} [props.beforeEach] A function to run before each step.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It adds a new feature to run something before each step. Similar to what we have in tests to reset or prepare something. In the future, if needed it could have some more events like this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

@@ -42,11 +42,17 @@ describe( 'SenseiTourKit', () => {
Close
</button>
<button
data-testid="nextButton"
data-testid="stepViewOnceButton"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I renamed this one since it's tied to the onStepViewOnce callback, and I added another one tied to the onNextStep callback, so I could use it in the new test.

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense!

Copy link

Test the previous changes of this PR with WordPress Playground.

Copy link

Test the previous changes of this PR with WordPress Playground.

Copy link

Test the previous changes of this PR with WordPress Playground.

Copy link

Test the previous changes of this PR with WordPress Playground.

@renatho
Copy link
Contributor Author

renatho commented Mar 15, 2024

Thank you for the review, @Imran92! I added a fix for the points 1 and 2: 24de088

About the point 3, I noticed that it only happens if the block is already visible in your viewport but in a bad position (almost out). If it's completely out, Gutenberg will moving it to a good position.

Screen.Recording.2024-03-15.at.16.15.47.mov

As a workaround, I thought of adding a temporary fade in the tour, do the user sees what's behind, but the experience didn't look nice. So I'd consider it as an edge case and just ignore. WDYT? I'm a little afraid to try to manipulate the scroll and be more error-prone in the future (in Gutenberg updates, for example).

@renatho renatho requested a review from Imran92 March 15, 2024 19:24
Imran92
Imran92 previously approved these changes Mar 18, 2024
Copy link
Contributor

@Imran92 Imran92 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 addressing the comments! LGTM!

Just a couple of comments, but I'm approving already.

  1. I've noticed that we are inserting a True/False question still in case the user has a question of that type in the second or later position. Do you think it'll be better we can use the True/False question regardless of the position and insert only as a last resort? I don't have a strong opinion. Current behavior can be okay too.
  2. As we have a number of helper functions on top, do you think we should write some tests for just those functions? Not necessary, but can be good to have.
  3. This one feels a little important to me, because I missed the focus outline multiple times even after knowing it should be there. That is, for Quiz and Question settings, we are highlighting the sidebar. But currently, the outline is only on the left side. So it's not too clear what we are highlighting-
Screen.Recording.2024-03-18.at.4.21.34.PM.mov

Can we somehow focus on the inner section of the side panel?

@renatho
Copy link
Contributor Author

renatho commented Mar 18, 2024

@Imran92! I will still work on the other 2 items, but I already sent a purpose for the last one for you too see what you think.

This one feels a little important to me, because I missed the focus outline multiple times even after knowing it should be there. That is, for Quiz and Question settings, we are highlighting the sidebar. But currently, the outline is only on the left side. So it's not too clear what we are highlighting-

Screenshot 2024-03-18 at 11 55 39 Screenshot 2024-03-18 at 12 16 23

The commits with the changes are:
459a817 62e0b56 5248885

Copy link

Test the previous changes of this PR with WordPress Playground.

Copy link

Test the previous changes of this PR with WordPress Playground.

@renatho
Copy link
Contributor Author

renatho commented Mar 18, 2024

@Imran92, for the other 2 items:

I've noticed that we are inserting a True/False question still in case the user has a question of that type in the second or later position. Do you think it'll be better we can use the True/False question regardless of the position and insert only as a last resort? I don't have a strong opinion. Current behavior can be okay too.

Implementation changed in: a125540

As we have a number of helper functions on top, do you think we should write some tests for just those functions? Not necessary, but can be good to have.

I wrote tests to cover the cases there in this commit: 0538655

@renatho renatho requested a review from Imran92 March 18, 2024 19:49
Copy link

Test the previous changes of this PR with WordPress Playground.

Imran92
Imran92 previously approved these changes Mar 19, 2024
Copy link
Contributor

@Imran92 Imran92 left a comment

Choose a reason for hiding this comment

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

Thanks Renatho! Looks good and works nice!

There's only one small issue I've noticed as a side effect of the last changes. Feel free to work on it separately if you want to. I'm approving already

When we minimize a tour, we remove all the highlighting, just like GB tour's spotlight. I noticed that the suffixed highlights are not getting removed like that-

Screen.Recording.2024-03-19.at.5.55.38.PM.mov

@renatho
Copy link
Contributor Author

renatho commented Mar 19, 2024

Good catch, @Imran92! I didn't realize that.

I fixed it with da17671, and I'm merging this PR. But a post-merge check is welcome, and I could fix anything in another PR if needed.

While working on this, I just realized another bad thing, but I couldn't find any good solution for that. If you don't have any idea too, I think we could live with it. The only thing I could think of is trying to override that hover class to not add the hover style, but it seems very fragile to me, which could cause other issues on Gutenberg updates.

Screenshot 2024-03-19 at 11 43 23

Copy link

Test the previous changes of this PR with WordPress Playground.

@renatho renatho merged commit 6190ee1 into trunk Mar 19, 2024
23 of 25 checks passed
@renatho renatho deleted the add/interaction-on-lesson-step branch March 19, 2024 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add interactivity in Lesson (Quiz) tour steps (focus on block/element/options etc, insert block etc)
2 participants