Skip to content

Commit 93b6593

Browse files
committed
Fixing issues related with layout rendering and box highlighting (along with related bugs).
1 parent 6aeb6c6 commit 93b6593

File tree

6 files changed

+36
-46
lines changed

6 files changed

+36
-46
lines changed

src/components/widgets/Box/Box.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class Box extends Component {
2323
componentDidMount() {
2424
if (this.props.id && this.props.location.hash === `#${this.props.id}`) {
2525
window.location.hash = this.props.location.hash;
26+
window.scrollBy({ top: -65, behavior: 'instant' }); // 65 is slightly more than LTE top-bar (which is 57px in height)
2627
}
2728
}
2829

src/containers/App/recodex.css

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,12 +296,13 @@ a:focus {
296296
.card:target {
297297
/*box-shadow: 0 0 5px 2px #fd6!important;*/
298298
animation: 3s ease infinite running card-target;
299-
border-color: #fe9 !important;
300-
border-bottom: 1px solid;
301-
border-left: 1px solid;
302-
border-right: 1px solid;
299+
border-color: #ed3 !important;
300+
border-bottom: 2px solid;
301+
border-left: 2px solid;
302+
border-right: 2px solid;
303303
}
304304

305+
305306
.whenTargetted {
306307
display: none;
307308
}

src/containers/LayoutContainer/LayoutContainer.js

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,24 @@ const ADDITIONAL_INTL_FORMATS = {
3838
* Also controls the state of the sidebar - collapsing and showing the sidebar.
3939
*/
4040
class LayoutContainer extends Component {
41+
newPageLoading = false;
42+
pageHeight = 0;
43+
44+
_scrollTargetToView() {
45+
if ((window.location.hash || this.props.location.hash) && this.pageHeight !== document.body.scrollHeight) {
46+
// this will enforce immediate scroll-to-view
47+
window.location.hash = this.props.location.hash;
48+
window.scrollBy({ top: -65, behavior: 'instant' }); // 65 is slightly more than LTE top-bar (which is 57px in height)
49+
this.pageHeight = document.body.scrollHeight; // make sure we scroll only if the render height changes
50+
}
51+
}
52+
4153
componentDidMount() {
4254
this.resizeSidebarToDefault(this.props);
43-
if (canUseDOM && (window.location.hash || this.props.location.hash)) {
44-
window.location.hash = this.props.location.hash;
55+
if (canUseDOM) {
56+
this.newPageLoading = true;
57+
this.pageHeight = -1;
58+
this._scrollTargetToView();
4559
}
4660
}
4761

@@ -54,8 +68,12 @@ class LayoutContainer extends Component {
5468
this.resizeSidebarToDefault(this.props);
5569
}
5670

57-
if (canUseDOM && (window.location.hash || this.props.location.hash)) {
58-
window.location.hash = this.props.location.hash;
71+
if (canUseDOM && this.newPageLoading) {
72+
this._scrollTargetToView();
73+
}
74+
75+
if (!this.props.pendingFetchOperations) {
76+
this.newPageLoading = false;
5977
}
6078
}
6179

src/pages/AssignmentSolutions/AssignmentSolutions.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,8 @@ class AssignmentSolutions extends Component {
544544
{viewModes[this.state.viewMode] || ''}
545545
</>
546546
}
547-
id="dropdown-menu-align-right">
547+
className="elevation-2"
548+
id="viewModeDropdown">
548549
<Dropdown.Header>
549550
<FormattedMessage
550551
id="app.assignmentSolutions.viewModesTitle"

src/pages/EditExerciseLimits/EditExerciseLimits.js

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import PropTypes from 'prop-types';
33
import ImmutablePropTypes from 'react-immutable-proptypes';
44
import { FormattedMessage } from 'react-intl';
55
import { Row, Col } from 'react-bootstrap';
6-
import { withRouter } from 'react-router';
76
import { connect } from 'react-redux';
87
import { defaultMemoize } from 'reselect';
98
import { formValueSelector } from 'redux-form';
@@ -88,18 +87,7 @@ class EditExerciseLimits extends Component {
8887
);
8988

9089
transformAndSendHardwareGroups = defaultMemoize((hwGroupId, limits) => {
91-
const {
92-
setExerciseHardwareGroups,
93-
setExerciseLimits,
94-
reloadExercise,
95-
invalidateExercise,
96-
history: { replace },
97-
location: { pathname, search, hash },
98-
} = this.props;
99-
100-
if (hash) {
101-
replace(pathname + search);
102-
}
90+
const { setExerciseHardwareGroups, setExerciseLimits, reloadExercise, invalidateExercise } = this.props;
10391

10492
const limitsData = limits && limits[hwGroupId];
10593
return formData =>
@@ -116,15 +104,7 @@ class EditExerciseLimits extends Component {
116104
});
117105

118106
transformAndSendLimitsValues = defaultMemoize((hwGroupId, tests, exerciseRuntimeEnvironments) => {
119-
const {
120-
setExerciseLimits,
121-
reloadExercise,
122-
history: { replace },
123-
location: { pathname, search, hash },
124-
} = this.props;
125-
if (hash) {
126-
replace(pathname + search);
127-
}
107+
const { setExerciseLimits, reloadExercise } = this.props;
128108
return formData =>
129109
setExerciseLimits(transformLimitsValues(formData, hwGroupId, exerciseRuntimeEnvironments, tests)).then(
130110
reloadExercise
@@ -317,15 +297,6 @@ EditExerciseLimits.propTypes = {
317297
cloneAll: PropTypes.func.isRequired,
318298
reloadExercise: PropTypes.func.isRequired,
319299
invalidateExercise: PropTypes.func.isRequired,
320-
history: PropTypes.shape({
321-
push: PropTypes.func.isRequired,
322-
replace: PropTypes.func.isRequired,
323-
}),
324-
location: PropTypes.shape({
325-
pathname: PropTypes.string.isRequired,
326-
search: PropTypes.string.isRequired,
327-
hash: PropTypes.string.isRequired,
328-
}).isRequired,
329300
};
330301

331302
const cloneVerticallyWrapper = defaultMemoize(
@@ -384,4 +355,4 @@ export default connect(
384355
reloadExercise: () => dispatch(fetchExercise(exerciseId)),
385356
invalidateExercise: () => dispatch(invalidateExercise(exerciseId)),
386357
})
387-
)(withRouter(EditExerciseLimits));
358+
)(EditExerciseLimits);

src/redux/selectors/groups.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@ const getParam = (_, id) => id;
1717
const getGroups = state => state.groups;
1818
export const groupsSelector = state => state.groups.get('resources');
1919

20-
export const notArchivedGroupsSelector = state =>
21-
state.groups
22-
.get('resources')
23-
.filter(isReady)
24-
.filter(group => group.getIn(['data', 'archived']) === false);
20+
export const notArchivedGroupsSelector = createSelector(groupsSelector, groups =>
21+
groups.filter(isReady).filter(group => group.getIn(['data', 'archived']) === false)
22+
);
2523

2624
export const groupSelector = createSelector([groupsSelector, getParam], (groups, id) => groups.get(id));
2725

0 commit comments

Comments
 (0)