Commit 791c4bf2 authored by Lyza Danger Gardner's avatar Lyza Danger Gardner Committed by Lyza Gardner

Fully un-set user-focus filter when empty user is passed

Fix a UI confusion by fully un-setting the user-focus filter if a
empty user value is provided to the `changeFocusModeUser` RPC method.

This prevents a confusing half-set user-focus filter from sticking
around when an instructor returns to viewing all users in grading mode
after focusing on one or more students.
parent 05c45f9a
......@@ -106,14 +106,9 @@ function focusFiltersFromConfig(focusConfig) {
const reducers = {
CHANGE_FOCUS_MODE_USER: function (state, action) {
if (isValidFocusConfig({ user: action.user })) {
return {
focusActive: true,
focusFilters: focusFiltersFromConfig({ user: action.user }),
};
}
return {
focusActive: false,
focusActive: isValidFocusConfig({ user: action.user }),
focusFilters: focusFiltersFromConfig({ user: action.user }),
};
},
......
......@@ -36,14 +36,26 @@ describe('sidebar/store/modules/filters', () => {
//
// This is the LMS app's way of asking the client to disable focus mode.
it('deactivates and disables focus if username is undefined', () => {
store.toggleFocusMode(true);
// Set to a valid user first; this will set and also activate
// the filter
store.changeFocusModeUser({
username: 'testuser',
displayName: 'Test User',
});
const firstFilterState = getFiltersState();
assert.isTrue(firstFilterState.focusActive);
assert.equal(firstFilterState.focusFilters.user.value, 'testuser');
// Now, emulate the "empty" filter message from the LMS app.
store.changeFocusModeUser({
username: undefined,
displayName: undefined,
});
const filterState = getFiltersState();
assert.isFalse(filterState.focusActive);
assert.isUndefined(filterState.focusFilters.user);
const secondFilterState = getFiltersState();
assert.isFalse(secondFilterState.focusActive);
assert.isUndefined(secondFilterState.focusFilters.user);
});
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment