Skip to content

Commit

Permalink
Add padding on the right of the text input depending on the size of t…
Browse files Browse the repository at this point in the history
…he buttons div
  • Loading branch information
jochenklar committed Jan 31, 2025
1 parent 4579339 commit ee4b281
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useEffect, useRef } from 'react'
import React, { useState, useEffect, useLayoutEffect, useRef } from 'react'
import PropTypes from 'prop-types'
import classNames from 'classnames'
import { useDebouncedCallback } from 'use-debounce'
Expand All @@ -15,6 +15,13 @@ const TextInput = ({ question, value, disabled, updateValue, buttons }) => {

useEffect(() => {setInputValue(value.text)}, [value.text])
useFocusEffect(ref, value.focus)
useLayoutEffect(() => {
if (ref.current) {
// add a right padding of the size of the buttons div, plus some space for the success indicator
const buttonsWidth = ref.current.previousElementSibling.offsetWidth + 20
ref.current.style.paddingRight = `${buttonsWidth}px`
}
}, [buttons])

const handleChange = useDebouncedCallback((value, text) => {
updateValue(value, { text, unit: question.unit, value_type: question.value_type })
Expand Down
4 changes: 4 additions & 0 deletions rdmo/projects/assets/scss/interview.scss
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@
text-overflow: ellipsis;
}

input[type="text"] {
text-overflow:ellipsis;
}

.radio,
.checkbox {
margin: 0;
Expand Down

0 comments on commit ee4b281

Please sign in to comment.