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

input should not affect the column width #798

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions R/datatables.R
Original file line number Diff line number Diff line change
Expand Up @@ -527,16 +527,16 @@ filterRow = function(
style = 'margin-bottom: auto;',
tags$input(
type = if (clear) 'search' else 'text', placeholder = 'All',
style = 'width: 100%;'
style = 'width: 100%;', size = "1"
)
)
} else {
tags$div(
class = if (clear) 'form-group has-feedback' else 'form-group',
class = if (clear) 'form-group has-feedback row' else 'form-group row',
style = 'margin-bottom: auto;',
tags$input(
type = 'search', placeholder = 'All', class = 'form-control',
style = 'width: 100%;'
type = 'search', placeholder = 'All', class = 'form-control input-sm',
style = 'width: 100%; padding-right: 0px;', size = "1"
),
if (clear) tags$span(
class = 'glyphicon glyphicon-remove-circle form-control-feedback'
Expand Down
7 changes: 4 additions & 3 deletions inst/htmlwidgets/datatables.js
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,8 @@ HTMLWidgets.widget({
(function(cell, current) {
var $cell = $(cell), html = $cell.html();
var _cell = table.cell(cell), value = _cell.data();
var $input = $('<input type="text">'), changed = false;
var $divInput = $('<div class="form-group row" style="margin-bottom:auto;"><input type="text" class="form-control form-control-sm" size="1"></div>');
var $input = $divInput.children("input"), changed = false;
if (!immediate) {
$cell.data('input', $input).data('html', html);
$input.attr('title', 'Hit Ctrl+Enter to finish editing, or Esc to cancel');
Expand All @@ -763,9 +764,9 @@ HTMLWidgets.widget({
if (inArray(_cell.index().column, disableCols)) {
$input.attr('readonly', '').css('filter', 'invert(25%)');
}
$cell.empty().append($input);
$cell.empty().append($divInput);
if (cell === current) $input.focus();
$input.css('width', '100%');
$input.css('width', '100%').css('padding-right', '0px');

if (immediate) $input.on('change', function() {
changed = true;
Expand Down