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

[Backport 2024.02.xx] #10158 painless accessibility improvements (#10159) #10547

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
16 changes: 16 additions & 0 deletions web/client/components/I18N/Localized.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ class Localized extends React.Component {
};
}

componentDidMount() {
this.updateDocumentLangAttribute();
}

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

render() {
let { children } = this.props;

Expand Down Expand Up @@ -63,6 +73,12 @@ class Localized extends React.Component {
};
}, {});
};

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

export default Localized;
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