-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Customize scroll behavior #3653
Conversation
cd5ea94
to
39bf542
Compare
|
||
const scrollable = document.querySelector('.webchat__basic-transcript__scrollable'); | ||
|
||
expect(scrollable.scrollTop).toBe( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this one test validation failed as well due to inequality due to rounding to nearest decimal
Expected: 353
Received: 352.6666564941406
not sure if you saw same error before or it is a problem with my browser/display?
and i am also thinking if we could give a margin of error to make test more resilient?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you running the tests under Docker (i.e. via Jest)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
packages/component/src/hooks/internal/useAcknowledgedActivity.js
Outdated
Show resolved
Hide resolved
packages/component/src/hooks/internal/useAcknowledgedActivity.js
Outdated
Show resolved
Hide resolved
packages/component/src/hooks/internal/useAcknowledgedActivity.js
Outdated
Show resolved
Hide resolved
packages/component/src/hooks/internal/useAcknowledgedActivity.js
Outdated
Show resolved
Hide resolved
packages/component/src/hooks/internal/useAcknowledgedActivity.js
Outdated
Show resolved
Hide resolved
packages/component/src/hooks/internal/useAcknowledgedActivity.js
Outdated
Show resolved
Hide resolved
// 1. The condition will become solely "at the bottom of the transcript" | ||
// 2. Auto-scroll will always scroll the transcript to the bottom | ||
// 3. Web Chat will always acknowledge all activities as it is at the bottom | ||
// 4. Acknowledge flag become useless |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add "therefore... + explanation"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added:
// 5. Therefore, even the developer set "pause after 3 activities", if activities are coming in at a slow pace (not batched in a single render)
// Web Chat will keep scrolling and not snapped/paused
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't see 5. added to the code yet, but looks good.
// 4. Acknowledge flag become useless | |
// 4. Acknowledge flag becomes useless | |
// 5. Therefore, when the developer sets "pause after 3 activities", if activities are coming in at a slow pace (not batched in a single render) | |
// Web Chat will keep scrolling and not become snapped/paused |
packages/component/src/hooks/internal/useAcknowledgedActivity.js
Outdated
Show resolved
Hide resolved
packages/component/src/hooks/internal/useAcknowledgedActivity.js
Outdated
Show resolved
Hide resolved
packages/component/src/hooks/internal/useAcknowledgedActivity.js
Outdated
Show resolved
Hide resolved
packages/testharness/src/utils/createDirectLineWithTranscript.js
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - I approved (with comments), but since @amal-khalaf is reviewing as well, I recommend waiting for her approval too.
Co-authored-by: Corina <[email protected]>
…ramework-WebChat into feat-custom-scroll
Hi @compulim , Hope you are doing well. I have two queries. 1.If we pass the scroll after 1 activity its working fine. But if we have a large content in the 1st message only again the scrollbar is going down. is there any way to focus on at staring of that first message. Thanks. |
HI @compulim , Can we implement this custom scroll behavior for specific responses. Is there any possibility to implement for only few responses. styleOptions = { Thanks . |
After updating the framwork-sdk to version: Styling options added for the chat rendering options:
Can someone shed some light on it? |
Hi @Elephantei , Try with below style options. autoScrollSnapOnActivity:2, |
Hi @Sandy2725 thank you for your help, this worked for us really well for a bit.
But now we updated to the last webchat version (4.15.2) and this just stopped working, not scrolling anymore at all as soon as the "page" is full with messages. I guess this is intended behavior of |
Changelog Entry
Added
autoScrollSnapOnActivity
totrue
to pause auto-scroll after more than one activity is shown, or a number to pause after X number of activitiesautoScrollSnapOnPage
totrue
to pause auto-scroll when a page is filled, or a number between0
and1
to pause after % of page is filledautoScrollSnapOnActivityOffset
andautoScrollSnapOnPageOffset
to a number (in pixels) to overscroll/underscroll after the pauseDescription
Added style options to customize scroll behavior by pausing at specified "snap point".
Currently, support 2 snap points:
In additional to snap points, 2 more options to specify number of pixels to overscroll or underscroll. If both options are specified, it will use the value that would pause the auto-scroll sooner.
The following video demonstrates the pause after 2 activities and 100 pixels. The cyan color indicates acknowledged activities and orange color indicates recently arrived activities. Equivalent to setting:
Media1.mp4
Design
Default behavior
By default, we did not enable this feature. We should consult our UX team before turning it on by default.
Activities acknowledgement
To pause, only unacknowledged activities are taken into account. For example, the page will pause after it filled with activities the user didn't positively indicate they have been read.
Acknowledgement means: activity is positively acknowledged by the user. If the user does not interact on Web Chat, no activities should be acknowledged.
Currently, we use 2 signals for indicating acknowledgement:
The signals above positively identify the user read the content.
Since the DLJS and other chat adapters do not keep this acknowledgement information, we will assume, when Web Chat started, all activities are acknowledged (e.g. restoring from conversation history). And it will stop auto-acknowledging when the user send their first message.
Due to the limitation of chat adapter, we recommend content author not to send initial activities (a.k.a. welcome messages) longer than a page.
Allowing multiple instances of
<BasicTranscript>
Last October, when we work on the feature to refactor some React components into API layer, the way we refactor
<BasicTranscript>
does not allow multiple instances of it inside the same composition (i.e.<Composer>
).In this PR, we also addressed it by allowing multiple instances of
<BasicTranscript>
, such as:Resolving #2884
In #2884, the developer prefers to pause "after 1 activity and 2.5 lines of text". Since line of text is not trivial to measure in HTML, we fallback to pixels instead.
To resolve #2884, the developer should set the following style options:
Specific Changes
<Composer>
and corresponding hooks to support multiple instances of<BasicTranscript>
useScrollTo
is being called, we will multiplex this call into all instances of<BasicTranscript>
, instead of oneautoScrollSnapOnActivity
,autoScrollSnapOnActivityOffset
,autoScrollSnapOnPage
,autoScrollSnapOnPageOffset
[email protected]
to support pausing at a specificscrollTop
position (Add scroller prop to programmatically pause scrolling andinitialScrollBehavior
compulim/react-scroll-to-bottom#73)CHANGELOG.md
Review Checklist
Accessibility reviewed (tab order, content readability, alt text, color contrast)CSS styles reviewed (minimal rules, noz-index
)Internationalization reviewed (strings, unit formatting)package.json
andpackage-lock.json
reviewed