• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

geosolutions-it / MapStore2 / 14359153796

09 Apr 2025 02:02PM UTC coverage: 76.955% (-0.03%) from 76.985%
14359153796

Pull #10950

github

web-flow
Merge c89fb6e0a into 3ad831e94
Pull Request #10950: Fix #10947 Updated dockerfile to static files for standard templates

31008 of 48285 branches covered (64.22%)

38489 of 50015 relevant lines covered (76.95%)

35.82 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

62.79
/web/client/components/data/grid/DataGrid.jsx
1
/*
2
 * Copyright 2017, GeoSolutions Sas.
3
 * All rights reserved.
4
 *
5
 * This source code is licensed under the BSD-style license found in the
6
 * LICENSE file in the root directory of this source tree.
7
 */
8
import PropTypes from 'prop-types';
9

10
import Grid from 'react-data-grid';
11
import ReactDOM from 'react-dom';
12

13
class DataGrid extends Grid {
14
    static propTypes = {
1✔
15
        displayFilters: PropTypes.bool
16
    }
17
    constructor(props) {
18
        super(props);
20✔
19
    }
20
    componentDidMount() {
21
        this.setCanvasListener();
20✔
22
        if (this.props.displayFilters) {
20✔
23
            this.onToggleFilter();
5✔
24
        }
25
    }
26
    componentWillUnmount() {
27
        if (this.canvas) {
20✔
28
            this.canvas.removeEventListener('scroll', this.scrollListener);
16✔
29
            this.canvas = null;
16✔
30
        }
31
        if (this.props.displayFilters) {
20✔
32
            this.onToggleFilter();
5✔
33
        }
34
    }
35
    componentDidUpdate(oldProps) {
36
        const { virtualScroll, displayFilters, scrollToTopCounter} = this.props;
15✔
37
        if (oldProps.displayFilters !== displayFilters) {
15!
38
            this.onToggleFilter();
×
39
        }
40
        if (virtualScroll) {
15✔
41
            // Check if canvas is always valid
42
            if (this.canvas && this.canvas !== ReactDOM.findDOMNode(this).querySelector('.react-grid-Canvas')) {
5!
43
                this.canvas.removeEventListener('scroll', this.scrollListener);
×
44
                this.setCanvasListener();
×
45
            }
46
            // Check if canvas exist
47
            if (!this.canvas) {
5!
48
                this.setCanvasListener();
5✔
49
            }
50
            // When exiting feature editing we reset previous scroll
51
            if (this.canvas && oldProps.isFocused && !this.props.isFocused ) {
5!
52
                this.canvas.scrollTop = this.scroll;
×
53
            } else if (this.canvas && this.props.minHeight !== oldProps.minHeight) {
5!
54
                this.scrollListener(); // Emit scroll on  grid resize
×
55
            }
56
            if (!this.props.isFocused && this.canvas) {
5!
57
                this.scroll = this.canvas.scrollTop;
×
58
            }
59
            // force scroll top
60
            if (scrollToTopCounter !== oldProps.scrollToTopCounter && this.canvas) {
5!
61
                this.canvas.scrollTop = 0;
×
62
            } else if (this.canvas && this.header) {
5!
63
                this.canvas.scrollLeft = this.header.scrollLeft; // makes sure header x-scroll matches canvas x-scroll
×
64
            }
65
        }
66
    }
67
    scrollListener = () => {
20✔
68
        if (this.props.rowsCount === 0) return;
×
69
        if (!this.props.isFocused && this.canvas) {
×
70
            this.scroll = this.canvas.scrollTop;
×
71
        }
72
        const visibleRows = Math.ceil(this.canvas.clientHeight / this.props.rowHeight);
×
73
        const firstRowIdx = Math.floor(this.canvas.scrollTop / this.props.rowHeight);
×
74
        const lastRowIdx = firstRowIdx + visibleRows;
×
75
        if (this.props.onGridScroll) {
×
76
            this.props.onGridScroll({ firstRowIdx, lastRowIdx });
×
77
        }
78
    }
79
    setCanvasListener = () => {
20✔
80
        this.canvas = ReactDOM.findDOMNode(this).querySelector('.react-grid-Canvas');
25✔
81
        this.header = ReactDOM.findDOMNode(this).querySelector('.react-grid-HeaderRow');
25✔
82
        if (this.canvas) {
25✔
83
            this.canvas.addEventListener('scroll', this.scrollListener);
16✔
84
        }
85
    }
86
}
87

88
export default DataGrid;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc