fix/focus-timer-view (#26)

* Auto focus button in timer view

* Revert find projects by identifier without alphanumerical characters

* Update changelog
This commit is contained in:
Manuel Bouza 2019-10-17 11:47:05 +02:00 committed by Tobias Miesel
parent 76d57729f4
commit 12c8b8e3eb
5 changed files with 12 additions and 19 deletions

View File

@ -5,14 +5,19 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased] ## [1.3.1] - 2019-10-17
- Add support for starting/stopping a timer ### Fixed
- Show hours as HH:MM or decimal in the Bubble, depending on setting in MOCO
- Set propper focus on timer view
### Removed
- Find projects by identifier without alphanumerical characters
## [1.3.0] - 2019-10-11 ## [1.3.0] - 2019-10-11
### Changed ### Added
- Start a new timer or stop a running timer - Start a new timer or stop a running timer
- Format time as set in time tracking - Format time as set in time tracking

View File

@ -1,7 +1,7 @@
{ {
"name": "moco-browser-extensions", "name": "moco-browser-extensions",
"description": "Browser plugin for MOCO", "description": "Browser plugin for MOCO",
"version": "1.3.0", "version": "1.3.1",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"start": "yarn start:chrome", "start": "yarn start:chrome",

View File

@ -25,7 +25,7 @@ export default function TimerView({ timedActivity, onStopTimer }) {
offset={timedActivity.seconds} offset={timedActivity.seconds}
style={{ fontSize: "36px", display: "inline-block" }} style={{ fontSize: "36px", display: "inline-block" }}
/> />
<button className="moco-bx-btn btn-stop-timer" onClick={handleStopTimer}> <button className="moco-bx-btn btn-stop-timer" onClick={handleStopTimer} autoFocus>
<StopWatch /> <StopWatch />
</button> </button>
</div> </div>

View File

@ -19,13 +19,6 @@ const Popup = forwardRef((props, ref) => {
} }
useEffect(() => { useEffect(() => {
// Document might lose focus when clicking the browser action.
// Document might be out of focus when hitting the shortcut key.
// This puts the focus back to the document and ensures that:
// - the autofocus on the hours input field is triggered
// - the ESC key closes the popup without closing anything else
window.focus()
document.activeElement?.blur()
window.addEventListener("message", handleMessage) window.addEventListener("message", handleMessage)
return () => { return () => {
window.removeEventListener("message", handleMessage) window.removeEventListener("message", handleMessage)

View File

@ -25,7 +25,6 @@ export const ERROR_UNKNOWN = "unknown"
export const noop = () => null export const noop = () => null
export const asArray = input => (Array.isArray(input) ? input : [input]) export const asArray = input => (Array.isArray(input) ? input : [input])
export const removeNonAlphanumChars = input => String(input ?? "").replace(/[\W_]/g, "")
export const findProjectBy = prop => val => projects => { export const findProjectBy = prop => val => projects => {
if (!val) { if (!val) {
@ -33,11 +32,7 @@ export const findProjectBy = prop => val => projects => {
} }
return compose( return compose(
find( find(pathEq(prop, val)),
project =>
project[prop] === val ||
removeNonAlphanumChars(project[prop]) === removeNonAlphanumChars(val),
),
flatMap(get("options")), flatMap(get("options")),
)(projects) )(projects)
} }