Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

textAreaInput() doesn't work as expected for relative width #2049

Closed
wants to merge 4 commits into from

Conversation

shrektan
Copy link
Contributor

@shrektan shrektan commented May 7, 2018

Example Code

library(shiny)
ui <- fluidPage(
  textAreaInput("text_area", "100% width text area", width = "100%"),
  hr(),
  p("compare the width to the horizontal line above")
)
server <- function(input, output) {
  
}
shiny::shinyApp(ui, server)

Before this PR

before

After this PR

after

@shrektan
Copy link
Contributor Author

Being bite again... Isn't it a bug?

@wch
Copy link
Collaborator

wch commented Aug 23, 2019

Am I correct that, if width is 50%, then both the wrapper div and the textarea have the width set to 50%, and so the resulting overall width of the textarea is 25%?

Merge remote-tracking branch 'origin/master' into textarea-style

# Conflicts:
#	R/input-textarea.R
@shrektan
Copy link
Contributor Author

@wch Thanks for pointing out this. Now it should have worked expectedly.

Example code

library(shiny)
charornull <- function(x) {
  if (nzchar(x)) x else NULL
}
ui <- fluidPage(
  inputPanel(
    textInput('area_width', 'area-width', '50%'),
    textInput('area_height', 'area-height', ''),
    textInput('area_rows', 'area-rows', ''),
    textInput('area_cols', 'area-cols', '')
  ),
  uiOutput('ui_text_area')
)
server <- function(input, output) {
  output$ui_text_area <- renderUI({
    textAreaInput("text_area", label = NULL, 
                  width = charornull(input$area_width),
                  height = charornull(input$area_height),
                  rows = charornull(input$area_rows),
                  cols = charornull(input$area_cols))
  })
}
shiny::shinyApp(ui, server)

Output

image

@CLAassistant
Copy link

CLAassistant commented Oct 2, 2019

CLA assistant check
All committers have signed the CLA.

@shrektan
Copy link
Contributor Author

@wch Not to push... but this has been opened for two and half years already...

Is there any potential drawbacks of this fix so it's hanged for so long ?

I'm asking this is because I use a lot of this function and being unable to set the pct of the width forces me to define a seperate function every time, which is ugly and inconvinient...

Would be highly appreciated if this issue can be fixed soon...

wch added a commit that referenced this pull request Oct 12, 2020
Squashed commit of the following:

commit a823dd5d7da6fafba69f783e112d71d9dcd09c5f
Author: Winston Chang <winston@stdout.org>
Date:   Mon Oct 12 12:59:41 2020 -0500

    Remove trailing whitespace

commit ae55b519fb0f7d97f559e2f487063366926aa41d
Author: Winston Chang <winston@stdout.org>
Date:   Mon Oct 12 12:52:04 2020 -0500

    Move NEWS item to correct location

commit aa89abc247be1bf5cdf093ff7fe7c51711821438
Merge: ee98773 a1ff765
Author: Winston Chang <winston@stdout.org>
Date:   Mon Oct 12 12:47:21 2020 -0500

    Merge branch 'master' into shrektan-textarea-style

commit ee98773
Author: shrektan <shrektan@126.com>
Date:   Sat Aug 24 10:35:23 2019 +0800

    correct the NEWS entry

commit b468d8f
Author: shrektan <shrektan@126.com>
Date:   Sat Aug 24 10:32:52 2019 +0800

    the width of textarea should be specified in the parent div.

commit 5abdcf9
Merge: 03079f0 b07e553
Author: shrektan <shrektan@126.com>
Date:   Sat Aug 24 09:54:27 2019 +0800

    resolve conflicts

    Merge remote-tracking branch 'origin/master' into textarea-style

    # Conflicts:
    #	R/input-textarea.R

commit 03079f0
Author: shrektan <shrektan@126.com>
Date:   Mon May 7 16:08:05 2018 +0800

    Fixed a bug that `textAreaInput()` doesn't work as expected for relative `width`.
@wch
Copy link
Collaborator

wch commented Oct 12, 2020

Sorry for the delay. I fixed the news locally and squash-merged it in c498b02.

@wch wch closed this Oct 12, 2020
@shrektan shrektan deleted the textarea-style branch October 12, 2020 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants