Skip to content
This repository has been archived by the owner on Jun 17, 2020. It is now read-only.

Commit

Permalink
Version 0.17.1
Browse files Browse the repository at this point in the history
  • Loading branch information
yuku committed Mar 31, 2018
1 parent b7a30bb commit 6f07195
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ This change log adheres to [keepachangelog.com](http://keepachangelog.com).

## [Unreleased]

## [0.17.1] - 2018-03-31
### Fixed
- Fix placement of dropdown menu in textarea with no line-height set.

## [0.17.0] - 2018-03-23
### Added
- Add hide method to textcomplete to deactivate dropdown manually
Expand Down Expand Up @@ -199,7 +203,8 @@ Textcomplete loses a lot of weight. Now it is smaller than jquery-textcomplete!
### Added
- Initial release.

[Unreleased]: https://github.com/yuku-t/textcomplete/compare/v0.17.0...HEAD
[Unreleased]: https://github.com/yuku-t/textcomplete/compare/v0.17.1...HEAD
[0.17.1]: https://github.com/yuku-t/textcomplete/compare/v0.17.0...v0.17.1
[0.17.0]: https://github.com/yuku-t/textcomplete/compare/v0.16.1...v0.17.0
[0.16.1]: https://github.com/yuku-t/textcomplete/compare/v0.16.0...v0.16.1
[0.16.0]: https://github.com/yuku-t/textcomplete/compare/v0.15.0...v0.16.0
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "textcomplete",
"version": "0.17.0",
"version": "0.17.1",
"description": "Autocomplete for textarea elements",
"main": "lib/index.js",
"scripts": {
Expand Down
10 changes: 5 additions & 5 deletions src/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,18 +182,18 @@ export default class Dropdown extends EventEmitter {

/** @private */
setOffset(cursorOffset: CursorOffset) {
const doc = document.documentElement;
const doc = document.documentElement
if (doc) {
const elementWidth = this.el.offsetWidth;
const elementWidth = this.el.offsetWidth
if (cursorOffset.left) {
const browserWidth = doc.clientWidth;
const browserWidth = doc.clientWidth
if (cursorOffset.left + elementWidth > browserWidth) {
cursorOffset.left = browserWidth - elementWidth;
cursorOffset.left = browserWidth - elementWidth
}
this.el.style.left = `${cursorOffset.left}px`
} else if (cursorOffset.right) {
if (cursorOffset.right - elementWidth < 0) {
cursorOffset.right = 0;
cursorOffset.right = 0
}
this.el.style.right = `${cursorOffset.right}px`
}
Expand Down
15 changes: 8 additions & 7 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,18 @@ export function getLineHeightPx(node: HTMLElement): number {

// Otherwise, the value is "normal".
// If the line-height is "normal", calculate by font-size
return calculateLineHeightPx(node.nodeName, computedStyle);
return calculateLineHeightPx(node.nodeName, computedStyle)
}


/**
* Returns calculated line-height of the given node in pixels.
*
* @private
*/
export function calculateLineHeightPx(nodeName: string, computedStyle: CSSStyleDeclaration): number {
export function calculateLineHeightPx(
nodeName: string,
computedStyle: CSSStyleDeclaration,
): number {
const body = document.body
if (!body) {
return 0
Expand All @@ -115,13 +117,12 @@ export function calculateLineHeightPx(nodeName: string, computedStyle: CSSStyleD
tempNode.innerHTML = "&nbsp;"
tempNode.style.fontSize = computedStyle.fontSize
tempNode.style.fontFamily = computedStyle.fontFamily
tempNode.style.padding = "0";
tempNode.style.padding = "0"
body.appendChild(tempNode)

// Make sure textarea has only 1 row
if (tempNode instanceof HTMLTextAreaElement)
{
(tempNode: HTMLTextAreaElement).rows = 1
if (tempNode instanceof HTMLTextAreaElement) {
;(tempNode: HTMLTextAreaElement).rows = 1
}

// Assume the height of the element is the line-height
Expand Down

0 comments on commit 6f07195

Please sign in to comment.