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

#10158 painless accessibility improvements #10159

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions web/client/components/I18N/Localized.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class Localized extends React.Component {
if (typeof children === 'function') {
children = children();
}
document.documentElement.setAttribute("lang", this.props.locale);
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be better to move this in componentDidMount and componentDidUpdate and remove it from the render method, it could be something like:

componentDidMount() {
    this.updateDocumentLangAttribute();
}

componentDidUpdate(prevProps) {
    if (this.props.locale !== prevProps.locale) {
        this.updateDocumentLangAttribute();
    }
}

updateDocumentLangAttribute() {
    if (document?.documentElement) {
        document.documentElement.setAttribute("lang", this.props.locale);
    }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the helpful review! Sorry for taking so long, I no longer work at DB Systel.


return (<IntlProvider key={this.props.locale} locale={this.props.locale}
messages={this.flattenMessages(this.props.messages)}
Expand Down
15 changes: 15 additions & 0 deletions web/client/components/I18N/__tests__/Localized-test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,21 @@ describe('Test the localization support HOC', () => {
expect(dom.innerHTML).toBe("my message");
});

it('correctly sets the document language', () => {
ReactDOM.render(
<Localized locale="it-IT" messages={messages}>
{() => <Message msgId="testMsg"/> }
</Localized>
, document.getElementById("container"));
expect(document.documentElement.lang).toBe("it-IT");
ReactDOM.render(
<Localized locale="de-DE" messages={messages}>
{() => <Message msgId="testMsg"/> }
</Localized>
, document.getElementById("container"));
expect(document.documentElement.lang).toBe("de-DE");
});

it('localizes wrapped HTML component', () => {
var localized = ReactDOM.render(
<Localized locale="it-IT" messages={messages}>
Expand Down
4 changes: 2 additions & 2 deletions web/client/components/mapcontrols/scale/ScaleBox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ class ScaleBox extends React.Component {
} else {
control =
(<Form inline><FormGroup bsSize="small">
<ControlLabel>{this.props.label}</ControlLabel>
<FormControl componentClass="select" onChange={this.onComboChange} value={currentZoomLvl || ""}>
<ControlLabel htmlFor="scaleBox">{this.props.label}</ControlLabel>
<FormControl id="scaleBox" componentClass="select" onChange={this.onComboChange} value={currentZoomLvl || ""}>
{this.getOptions()}
</FormControl>
</FormGroup></Form>)
Expand Down
2 changes: 1 addition & 1 deletion web/client/components/misc/PaginationToolbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class PaginationToolbar extends React.Component {
onSelect={this.onSelect} />
</Col>
<Col xs={12}>
<h5>{this.props.loading ? <Message msgId="loading"/> : msg}</h5>
<div>{this.props.loading ? <Message msgId="loading"/> : msg}</div>
</Col>
</Row>
);
Expand Down
2 changes: 1 addition & 1 deletion web/client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>MapStore HomePage</title>
<style>
body {
Expand Down
2 changes: 1 addition & 1 deletion web/client/indexTemplate.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>MapStore HomePage</title>
<style>
body {
Expand Down
2 changes: 1 addition & 1 deletion web/client/product/plugins/Attribution.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default {
position: 0,
label: props.label || 'GeoSolutions',
href: props.href || 'https://www.geosolutionsgroup.com/',
img: props.src && <img className="customer-logo" src={props.src} height="30" /> || <img className="customer-logo" src={src} height="30" />,
img: props.src && <img className="customer-logo" src={props.src} height="30" alt={props.label || 'GeoSolutions'} /> || <img className="customer-logo" src={src} height="30" alt={props.label || 'GeoSolutions'} />,
logo: true
})
}
Expand Down
Loading