mirror of
https://github.com/flarum/framework.git
synced 2024-12-01 22:43:41 +08:00
Fix tag selection input on discussion modal going out of screen (#83)
Calculate width of input field dynamically based on content, this fixes the bug by only shifting tags out of view when necessary
This commit is contained in:
parent
cda9ed9fca
commit
274f31b6bf
|
@ -148,11 +148,15 @@ export default class TagDiscussionModal extends Modal {
|
|||
|
||||
if (tags.indexOf(this.index) === -1) this.index = tags[0];
|
||||
|
||||
const inputWidth = Math.max(extractText(this.getInstruction(primaryCount, secondaryCount)).length, this.filter().length);
|
||||
|
||||
return [
|
||||
<div className="Modal-body">
|
||||
<div className="TagDiscussionModal-form">
|
||||
<div className="TagDiscussionModal-form-input">
|
||||
<div className={'TagsInput FormControl ' + (this.focused ? 'focus' : '')}>
|
||||
<div className={'TagsInput FormControl ' + (this.focused ? 'focus' : '')}
|
||||
onclick={() => this.$('.TagsInput input').focus()}
|
||||
>
|
||||
<span className="TagsInput-selected">
|
||||
{this.selected.map(tag =>
|
||||
<span className="TagsInput-tag" onclick={() => {
|
||||
|
@ -166,6 +170,7 @@ export default class TagDiscussionModal extends Modal {
|
|||
<input className="FormControl"
|
||||
placeholder={extractText(this.getInstruction(primaryCount, secondaryCount))}
|
||||
value={this.filter()}
|
||||
style={{ width: inputWidth + 'ch' }}
|
||||
oninput={m.withAttr('value', this.filter)}
|
||||
onkeydown={this.navigator.navigate.bind(this.navigator)}
|
||||
onfocus={() => this.focused = true}
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
padding-bottom: 0;
|
||||
overflow: hidden;
|
||||
height: auto;
|
||||
cursor: text;
|
||||
|
||||
input {
|
||||
display: inline;
|
||||
|
@ -51,7 +52,7 @@
|
|||
margin-top: -2px;
|
||||
border: 0 !important;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
margin-right: -100%;
|
||||
background: transparent !important;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user