mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
scroll instead of anchor, closed button tags
This commit is contained in:
parent
9b99b17cea
commit
b7733a2ae5
2 changed files with 13 additions and 9 deletions
|
@ -88,10 +88,10 @@ describe('Image upload form', () => {
|
|||
<input id="image_sources_0_source" name="image[sources][0][source]" type="text" class="js-source-url" />
|
||||
<textarea id="image_tag_input" name="image[tag_input]" class="js-image-tags-input"></textarea>
|
||||
<div class="js-taginput" value="safe, pony, third tag"/>
|
||||
<button id="tagsinput-save" type="button" class="button"/>
|
||||
<button id="tagsinput-save" type="button" class="button">Save</button>
|
||||
<textarea id="image_description" name="image[description]" class="js-image-descr-input"></textarea>
|
||||
<div class="actions">
|
||||
<button class="button" type="submit"/>
|
||||
<button class="button" type="submit">Upload</button>
|
||||
</div>
|
||||
</form>`,
|
||||
);
|
||||
|
|
|
@ -248,11 +248,15 @@ function setupImageUpload() {
|
|||
requestAnimationFrame(() => submitButton.setAttribute('disabled', 'disabled'));
|
||||
}
|
||||
|
||||
function anchorToTop() {
|
||||
let url = window.location.href;
|
||||
url = url.split('#')[0]; //remove any existing hash anchor from url
|
||||
url += '#taginput-fancy-tag_input'; //move view to tags input
|
||||
window.location.href = url;
|
||||
function scrollToTags() {
|
||||
const taginputEle = $('#taginput-fancy-tag_input');
|
||||
|
||||
if (!taginputEle) {
|
||||
// default to scroll to top
|
||||
window.scrollTo({ top: 0, left: 0 });
|
||||
}
|
||||
|
||||
taginputEle.scrollIntoView();
|
||||
}
|
||||
|
||||
function submitHandler(event) {
|
||||
|
@ -268,8 +272,8 @@ function setupImageUpload() {
|
|||
|
||||
// Let the form submission complete
|
||||
} else {
|
||||
// Scroll to the top of page to see validation errors
|
||||
anchorToTop();
|
||||
// Scroll to view validation errors
|
||||
scrollToTags();
|
||||
|
||||
// allow users to re-submit the form
|
||||
enableUploadButton();
|
||||
|
|
Loading…
Reference in a new issue