mirror of https://github.com/laurent22/joplin.git
* Fix undefined showButtonLabels * Add showButtonLabels to the state; Removed conditional statement checking if state is undefinedpull/2623/head
parent
55847fa22f
commit
a28b790256
|
@ -10,6 +10,7 @@ class HeaderComponent extends React.Component {
|
|||
this.state = {
|
||||
searchQuery: '',
|
||||
showSearchUsageLink: false,
|
||||
showButtonLabels: true,
|
||||
};
|
||||
|
||||
this.scheduleSearchChangeEventIid_ = null;
|
||||
|
@ -83,17 +84,14 @@ class HeaderComponent extends React.Component {
|
|||
}
|
||||
|
||||
if (this.props.zoomFactor !== prevProps.zoomFactor || this.props.size !== prevProps.size) {
|
||||
const mediaQuery = window.matchMedia(`(max-width: ${550 * this.props.zoomFactor}px)`);
|
||||
const showButtonLabels = !mediaQuery.matches;
|
||||
|
||||
if (this.state.showButtonLabels !== showButtonLabels) {
|
||||
this.setState({
|
||||
showButtonLabels: !mediaQuery.matches,
|
||||
});
|
||||
}
|
||||
this.determineButtonLabelState();
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.determineButtonLabelState();
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
if (this.hideSearchUsageLinkIID_) {
|
||||
clearTimeout(this.hideSearchUsageLinkIID_);
|
||||
|
@ -101,6 +99,17 @@ class HeaderComponent extends React.Component {
|
|||
}
|
||||
}
|
||||
|
||||
determineButtonLabelState() {
|
||||
const mediaQuery = window.matchMedia(`(max-width: ${550 * this.props.zoomFactor}px)`);
|
||||
const showButtonLabels = !mediaQuery.matches;
|
||||
|
||||
if (this.state.showButtonLabels !== showButtonLabels) {
|
||||
this.setState({
|
||||
showButtonLabels: !mediaQuery.matches,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async doCommand(command) {
|
||||
if (!command) return;
|
||||
|
||||
|
|
Loading…
Reference in New Issue