Skip to content

Commit

Permalink
Restore detection of text direction on Chrome
Browse files Browse the repository at this point in the history
  • Loading branch information
Anup Narkhede committed May 15, 2023
1 parent 5ef6f86 commit 20e8548
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/trix/core/helpers/bidi.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ const RTL_PATTERN =

export const getDirection = (function() {
const input = makeElement("input", { dir: "auto", name: "x", dirName: "x.dir" })
const textArea = makeElement("textarea", { dir: "auto", name: "y", dirName: "y.dir" })
const form = makeElement("form")
form.appendChild(input)
form.appendChild(textArea)

const supportsDirName = (function() {
try {
Expand All @@ -27,8 +29,8 @@ export const getDirection = (function() {

if (supportsDirName) {
return function(string) {
input.value = string
return new FormData(form).get(input.dirName)
input.value = textArea.value = string
return new FormData(form).get(textArea.dirName)
}
} else if (supportsDirSelector) {
return function(string) {
Expand Down

0 comments on commit 20e8548

Please sign in to comment.