From 328b8a5573668b192009fd348c38bd36b19323c8 Mon Sep 17 00:00:00 2001 From: Gabriel Bull Date: Fri, 24 Jun 2016 17:09:15 -0400 Subject: [PATCH] Fixed bug with title bar in macOS --- CHANGELOG.md | 4 ++++ package.json | 2 +- src/titleBar/macOs/titleBar.js | 32 +++++++++++++++++--------------- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6eed468b..de60d5c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## 0.2.3 (June 24th, 2016) + +- Fixed bug with title bar in macOS + ## 0.2.2 (June 24th, 2016) - Added Link component for macOS diff --git a/package.json b/package.json index 031f0f19..b106dd93 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "react-desktop", "author": "Gabriel Bull", - "version": "0.2.2", + "version": "0.2.3", "description": "React UI Components for macOS Sierra and Windows 10", "main": "./index.js", "keywords": [ diff --git a/src/titleBar/macOs/titleBar.js b/src/titleBar/macOs/titleBar.js index 572d00c6..8c111001 100644 --- a/src/titleBar/macOs/titleBar.js +++ b/src/titleBar/macOs/titleBar.js @@ -30,21 +30,23 @@ class TitleBar extends Component { } resize = () => { - const barRect = this.refs.element.getBoundingClientRect(); - this.refs.title.style.overflow = 'visible'; - this.refs.title.style.paddingRight = 0; - this.refs.title.style.flexGrow = 0; - const titleRect = this.refs.title.getBoundingClientRect(); - this.refs.title.style.overflow = 'hidden'; - this.refs.title.style.flexGrow = 1; - - const barWidth = barRect.width - 6; - const contentWidth = titleRect.width + (this.props.controls ? 60 : 0); - - let padding = barWidth - contentWidth; - if (padding > 60) padding = 60; - - this.refs.title.style.paddingRight = (padding) + 'px'; + if (this.refs.title) { + const barRect = this.refs.element.getBoundingClientRect(); + this.refs.title.style.overflow = 'visible'; + this.refs.title.style.paddingRight = 0; + this.refs.title.style.flexGrow = 0; + const titleRect = this.refs.title.getBoundingClientRect(); + this.refs.title.style.overflow = 'hidden'; + this.refs.title.style.flexGrow = 1; + + const barWidth = barRect.width - 6; + const contentWidth = titleRect.width + (this.props.controls ? 60 : 0); + + let padding = barWidth - contentWidth; + if (padding > 60) padding = 60; + + this.refs.title.style.paddingRight = (padding) + 'px'; + } }; render() {