Skip to content

Commit 0b3a46f

Browse files
committed
Update padding and fade to calc from row height
1 parent bbd45ab commit 0b3a46f

2 files changed

Lines changed: 21 additions & 9 deletions

File tree

cypress/tests/widgets/text-input.spec.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,23 @@ describe('Node/-RED Dashboard 2.0 - Text Input Widget', () => {
2222
cy.get('#nrdb-ui-widget-c1d2e3f4a5b60718 .v-field__field label').should('contain', 'Marking Notes')
2323
})
2424

25-
// Regression test for #2008: textarea must keep its top padding so the
26-
// floating label doesn't overlap the text (not collapsed to the global 2px).
27-
it('keeps top padding in textarea mode so the label does not overlap the text', () => {
28-
cy.get('#nrdb-ui-widget-c1d2e3f4a5b60718 textarea')
29-
.parents('.v-field').first()
30-
.find('.v-field__input')
31-
.should('have.css', 'padding-top', '12px')
25+
// Textarea padding is derived from the row height so the label clears the text
26+
// without growing the row, scaling across densities (32/38/48px).
27+
const densities = [
28+
{ name: 'compact (32px row)', cls: 'nrdb-view-density--compact', top: '4px', bottom: '0px' },
29+
{ name: 'comfortable (38px row)', cls: 'nrdb-view-density--comfortable', top: '7px', bottom: '3px' },
30+
{ name: 'default (48px row)', cls: 'nrdb-view-density--default', top: '12px', bottom: '8px' }
31+
]
32+
densities.forEach(({ name, cls, top, bottom }) => {
33+
it(`derives textarea padding from the row height at ${name}`, () => {
34+
cy.get('.nrdb-app')
35+
.invoke('removeClass', 'nrdb-view-density--compact nrdb-view-density--comfortable nrdb-view-density--default')
36+
.invoke('addClass', cls)
37+
cy.get('#nrdb-ui-widget-c1d2e3f4a5b60718 textarea')
38+
.parents('.v-field').first()
39+
.find('.v-field__input')
40+
.should('have.css', 'padding-top', top)
41+
.and('have.css', 'padding-bottom', bottom)
42+
})
3243
})
3344
})

ui/src/widgets/ui-text-input/UITextInput.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,10 @@ export default {
179179
<style lang="scss">
180180
.nrdb-ui-textarea {
181181
height: 100%; /* Ensure the textarea takes full height */
182+
--v-input-padding-top: max(4px, calc(var(--widget-row-height) / 2 - 12px));
182183
&.v-input .v-field--variant-outlined {
183-
--v-field-input-padding-top: 12px;
184-
--v-field-input-padding-bottom: 12px;
184+
--v-field-input-padding-top: max(4px, calc(var(--widget-row-height) / 2 - 12px));
185+
--v-field-input-padding-bottom: max(0px, calc(var(--widget-row-height) / 2 - 16px));
185186
}
186187
&.v-input--horizontal{
187188
&:has(textarea) {

0 commit comments

Comments
 (0)